GIFs animées : smoking


smoking.png
#!/bin/bash

SOURCE=smoking.png
DELAY=10                     # between frames of the GIF animation
INCREM=3                     # step for the main computing loop
TMPIMG=/tmp/tmp.pnm
WORKIMG=/tmp/work.pnm

# ---------------------------------------------------------

largeur=$(identify -format '%w' $SOURCE)
hauteur=$(identify -format '%h' $SOURCE)

for i in $(seq 4 $INCREM 100)
do
	dest=/tmp/montage_a_$(printf "%03d" $i).pnm
	convert -resize $i% $SOURCE $TMPIMG

	larg=$(identify -format '%w' $TMPIMG)
	haut=$(identify -format '%h' $TMPIMG)

	Y=$(( ($largeur-$larg)/2 ))
	X=$(( ($hauteur-$haut)/2 ))
	figlet -W at $Y , $X

	pngtopnm $SOURCE | pnminvert > $WORKIMG
	pnmpaste < $WORKIMG -replace $TMPIMG $Y $X > $dest

	y1=$(($Y+9))
	y2=$(($Y+7))
	
	convert 				\
		-fill black  -pointsize 72	\
		-annotate +${y1}+431 'Smoking' 	\
		-fill white  -pointsize 72	\
		-annotate +${y2}+429 'Smoking' 	\
		$dest $dest
done 

Quelques explications ?

La ligne largeur=$(identify -format '%w' $SOURCE) permet de récupérer la largeur (width '%w') en pixels de l'image dont le nom de fichier est dans $SOURCE. De même pour la hauteur.

Ensuite nous allons faire une boucle avec un compteur qui démarre à 4 et va justqu'à 100 avec un pas de $INCREM.