====== Compare folder contents ====== ===== Find incoherence in your backups ===== ~/multimedia$ find ./photographs/ -type f -exec sha1sum {} \; | sort > dir1_sha1 ~/multimedia$ cd /mnt/nas/ /mnt/nas$ find ./photographs/ -type f -exec sha1sum {} \; | sort > dir2_sha1 /mnt/nas$ diff --brief /home/cedric/multimedia/dir1_sha1 ./dir2_sha1 ====== Focal length repartition ====== #!/usr/bin/env python # -*- coding: utf-8 -*- import pylab import glob from collections import Counter from PIL import Image from PIL.ExifTags import TAGS DIRECTORY = "/home/cedric/vienna/*.JPG" def get_exif(fn): ret = {} i = Image.open(fn) info = i._getexif() if info is not None: for tag, value in info.items(): decoded = TAGS.get(tag, tag) ret[decoded] = value return ret if __name__ == "__main__": cnt = Counter() pictures = glob.glob(DIRECTORY) focal = Counter() for picture in pictures: exif = get_exif(picture) if exif != {}: focal[exif['FocalLength'][0]] += 1 if focal: length = len(focal) ind = pylab.arange(length) width = 0.35 # bars width focal_list = [elem for elem in focal.keys()] focal_count = [elem for elem in focal.values()] max_focal_count = max(focal_count) # max focal_count p = pylab.bar(ind, focal_count, width, color='r') pylab.ylabel("Number of shots") pylab.xlabel("Focal length") pylab.title("Focal length repartition for " + str(sum(focal_count)) + " pictures") pylab.xticks(ind + (width / 2), focal_list) pylab.xlim(-width, len(ind)) # changing the ordinate scale according to the max. if max_focal_count <= 100: pylab.ylim(0, max_focal_count + 5) pylab.yticks(pylab.arange(0, max_focal_count + 5, 5)) elif max_focal_count <= 200: pylab.ylim(0, max_focal_count + 10) pylab.yticks(pylab.arange(0, max_focal_count + 10, 10)) elif max_focal_count <= 600: pylab.ylim(0, max_focal_count + 25) pylab.yticks(pylab.arange(0, max_focal_count + 25, 25)) elif max_focal_count <= 800: pylab.ylim(0, max_focal_count + 50) pylab.yticks(pylab.arange(0, max_focal_count + 50, 50)) for rect in p: height = rect.get_height() pylab.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), ha='center', va='bottom') pylab.show() else: print "No result." ====== Piwigo ====== ! /usr/local/bin/python -*- coding: utf-8 -*- """piwigo.py Usefull for your Piwigo gallery (http://www.piwigo.org/). ./piwigo ./photos ./thumbnail/ ./pwg_high/ ./original_image01.jpg . . ./original_imageN.jpg ./piwigo.py Resize images from /pwg_high (original images) directory in two size : - 128*128 pixels in ./piwigo/photos/thumbnail ; - 1024*768 pixels in ./piwigo/photos/ . """ __author__ = "Cedric Bonhomme" __date__ = "$Date: 2009/03/22 $" __copyright__ = "Copyright (c) 2009 Cedric Bonhomme" __license__ = "GPL v3" import re import os import Image def search_files(motif, root_path): """Return a list of tuple (path, files). Search fo files containing 'motif' that aren't symbolic links. """ result = [] w = os.walk(root_path) for (path, dirs, files) in w: for f in files: if re.compile(motif).search(f): # if not a symbolic link if not os.path.islink(os.path.join(path, f)): result.append((os.path.join(path, f), f)) return result images = search_files(".jpg", "./photos/pwg_high") for image in images: im = Image.open(image[0]) im_thumbnail = im.resize((128, 128), Image.ANTIALIAS) im_thumbnail.save("./photos/thumbnail/TN-" + image[1], quality = 100) im_slide = im.resize((1024, 768), Image.NEAREST) im_slide.save("./photos/" + image[1], quality = 100) """ Filter options to resize the image : Use nearest neighbour : Image.NEAREST Linear interpolation in a 2x2 environment : Image.BILINEAR Cubic spline interpolation in a 4x4 environment : Image.BICUBIC Best down-sizing filter : Image.ANTIALIAS """ On peut facilement ajouter le transfert FTP du résultat dans le dossier distant qui va bien. ====== Watermark avec ImageMagick ====== $ convert 16-04-2008_0167.jpg -font Arial -pointsize 40 -draw "gravity south > fill black text 0,12 'Cédric Bonhomme' > fill white text 1,11 'Cédric Bonhomme' " wmark_text_drawn.jpg ====== Effet Polaroid ====== $ convert picture.jpg -thumbnail 240 -bordercolor white -background black +polaroid picture-pola.png