Tutorial , HowTo, How-To ...

Il faut installer le package imagemagick (disponible sous Windows et GNU/Linux). La commande magique pour retailler une image de largeur 600, rajouter une bordure noire de 10 pixels, et mettre une signature en bas à droite :


convert original.jpg -resize 580 -size 1x20 -mattecolor Black -frame 10x10+5+5 xc:Black -background Black -append -gravity SouthEast -font shanghai.ttf -pointsize 20 -fill white -draw "text 10,0 '2006 - Thus0'" convert-original.jpg

Pour effectuer une rotation :


convert original.jpg -rotate 90 -resize 580 -size 1x20 -mattecolor Black -frame 10x10+5+5 xc:Black -background Black -append -gravity SouthEast -font shanghai.ttf -pointsize 20 -fill white -draw "text 10,0 '2006 - Thus0'" convert-original.jpg

- Image originale :

JPG - 325.7 ko
Image Originale
British Museum

- Image encadrée :

JPG - 322.5 ko
Image encadrée
British Museum

Automatiser (script shell)

Pour convertir toutes les images .jpg d’un répertoire, utilisez le script suivant :


#!/bin/sh

for picture in `find ./ -name '*.jpg'`
do
 size=`identify -formet "%wx%h" $picture`
 echo "$picture : $size"
 convert $picture -resize 580 -size 1x20 -mattecolor Black -frame 10x10+5+5 xc:Black -background Black -append -gravity SouthEast -font shanghai.ttf -pointsize 20 -fill white -draw "text 10,0 '2006 - Thus0'" convert-$picture
done

Rq : si vos images contiennent des espaces dans leur nom, cela fait planter le script. Si vous voulez enlever les espaces, cf. mon article : Remplacer les espaces par des underscores