Page 1 of 1

Animation with images and their title

Posted: 2015-12-04T02:29:46-07:00
by Amy
Hi everybody,

do you think it’s possible to create an animation in which for each image, its filename is also drawn.
It means, creating an animation with -draw "text ....MYTEXT" knowing that MYTEXT will be different for each image of the animation.

Sorry for my english... Thank you for your help :)

Re: Animation with images and their title

Posted: 2015-12-04T10:17:04-07:00
by fmw42
It is possible. Do you want the filename in the image or below it? What platform are you using and what version of Imagemagick.

Are there images onto which you want the text draw or is it just a colored background with text drawn on it.

Please read viewtopic.php?f=1&t=9620

Re: Animation with images and their title

Posted: 2015-12-08T06:34:38-07:00
by Amy
Thanks;
I'd rather get the filename below each image.
I am on linux ubuntu and I use ImageMagick 6.5.4-7 . For the moment, I create the animation with this command:

Code: Select all

convert -delay 50 -resize 640x480 -loop 2 ${Inputs[*]} $OutGif 
"Inputs" is my list of real jpg images, not just colored backgrounds.
Thank you very much.

Re: Animation with images and their title

Posted: 2015-12-08T11:00:38-07:00
by fmw42
try this

Code: Select all

montage -label "%f" ${Inputs[*]} -resize 640x480 -geometry +0+0 -tile 1x1 miff:- |\
convert -delay 50 - -loop 2 $OutGif 

Re: Animation with images and their title

Posted: 2015-12-08T16:25:55-07:00
by anthony
You can modify each image, before creating the animation
So have a look at image annotation...
http://www.imagemagick.org/Usage/annotating/

Finally you can do this on the fly by looping over the input images and outputing the result as a MIFF:- pipeline into the animation generating image. A simple example of this using montage was given by Fred (above), but using a loop will allow you to do more complex processing, one image at a time. This is detailed in
http://www.imagemagick.org/Usage/files/#miff_stream

Example based on given code...

Code: Select all

for image in "${Inputs[@]}"; do
   convert  "$image" {annotate the image} -resize 640x480  miff:-
done |
   convert miff:- -set delay 50 -loop 2 $OutGif
ASIDE: Note the shell scripting mechanic "${Inputs[@]}" which correctly preserves special characters like spaces in the input shell array. Using '*' in the expression will fail unexpectedly in many situations. Though technically this is shell scripting, not image processing.

Also look at the examples on Animation Modifications
http://www.imagemagick.org/Usage/anim_mods/

Re: Animation with images and their title

Posted: 2015-12-09T07:30:38-07:00
by Amy
I should extract a substring from each image file name so the "for" loop is the best approach.
Anthony'solution works fine! !thanks, thanks to fmw42 too.

Code: Select all

for image in "${Inputs[@]}"; do

   convert  "$image" -gravity South -background Grey -splice 0x20 -fill white -pointsize 15 -annotate +0+8 "${image:5:15}" -resize 640x480  miff:-
done |
   convert miff:- -set delay 50 -loop 2 $OutGift
 


Best regards

Re: Animation with images and their title

Posted: 2015-12-09T18:42:03-07:00
by anthony
Glad to have helped. I see you also used the "Splice and Draw" technique to add a label under the image. ;-)

Just remember this does change the ratio of dimensions of the resulting image and thus it is unlikely image will
resize to be exactly 640x480 (especially if the image did have a 4:3 aspect ratio to start with).

That is why drawing on top of the image may be better. Depends if you need to preserve the 4:3 aspect ratio of an image (say to match the output display) or not.

Also doing this before the resize means that if you apply the label to say a larger image than others in the sequence, the final label for that image after resizing may be smaller than the others. For example labelling a 640x480 image from a website, then a 2304x1728 image from my first digital camera, or a 3264x2448 from a modern mobile phone.

You probably should resize the image first (leaving space for the appended/spiced label) first.

Re: Animation with images and their title

Posted: 2015-12-09T18:48:18-07:00
by fmw42
If preserving aspect is important, then you might be better using my montage method or just writing into the image with -undercolor along with -annotate to allow the text to be seen easier.