combine gif with sliding text

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
plantmann
Posts: 5
Joined: 2016-08-14T16:18:58-07:00
Authentication code: 1151

combine gif with sliding text

Post by plantmann »

How can i combine an existing gif with a sliding text?
It should follow a head-motion - slide in from below wait a little and slide out down again.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: combine gif with sliding text

Post by snibgo »

Do you know how to read and write GIFs? Do you know how to write text on an image, at a given location? If not, then read the usage pages.

Is the motion defined mathematically? Such as: constant speed upwards at VX pixels per frame, then wait WT frames, then constant speed VY pixels per second? If so, then that defines the expressions for the text location.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: combine gif with sliding text

Post by fmw42 »

Please always provide your IM version and platform, since syntax and scripting differ.

Also if possible provide and example of what you want or a diagram or more clear explanation.

Please read the top-most topic in this forum at viewtopic.php?f=1&t=9620

Are you starting with a single gif image or a gif animation?

See
http://www.imagemagick.org/Usage/text/
http://www.imagemagick.org/script/comma ... s.php#roll
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/

As user snibgo suggested, first try adding text to a single image. Then try adding text in different locations. The script a loop to draw it at different locations at the incremental offset you want per frame.

You can also write the text onto a transparent background and slide it up or down using -roll and overlay it on the background image.

If you already have an animated gif, then you need to break it into individual frames and put the text where desired onto each frame.

Once you have a better understanding and provide more detailed explanation, we can help further.

Can you provide the gif image and the font you want to use and size and the text you want to show? You can post any images to some free hosting service such as dropbox.com and put the URL here.
plantmann
Posts: 5
Joined: 2016-08-14T16:18:58-07:00
Authentication code: 1151

Re: combine gif with sliding text

Post by plantmann »

Well i'm new to imagemagick, so i thought somebody could provide me a get-started script.

@fmw42
ImageMagick-7.0.2-7-portable-Q16-x64, win 7
gif animation + sliding watermark/text overlay.

http://i.imgur.com/WgiGGoe.gifv <--something like this + going down again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: combine gif with sliding text

Post by fmw42 »

This would be best done by scripting a loop. But I do not use Windows and scripting is different on Windows and Mac. So here are a few commands to make a simple animation.

lena.jpg
Image

Code: Select all

convert lena.jpg -fill white -font arial -pointsize 24 -gravity center -annotate +0+100 "testing" lena_text1.jpg
convert lena.jpg -fill white -font arial -pointsize 24 -gravity center -annotate +0+75 "testing" lena_text2.jpg
convert lena.jpg -fill white -font arial -pointsize 24 -gravity center -annotate +0+50 "testing" lena_text3.jpg
convert lena.jpg -fill white -font arial -pointsize 24 -gravity center -annotate +0+25 "testing" lena_text4.jpg
convert lena.jpg -fill white -font arial -pointsize 24 -gravity center -annotate +0+0 "testing" lena_text5.jpg
convert -delay 50 lena_text*.jpg -loop 0 -layers optimize lena_anim.gif
Image

or for the last command

Code: Select all

convert -delay 50 lena_text*.jpg ( -clone 0--1 -reverse ) -loop 0 -layers optimize lena_anim2.gif
Image


See the reference I provided earlier for the details of the commands. Also see
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/basics/#reverse
http://www.imagemagick.org/Usage/windows/

Once you understand this, then you can either script it or it should be possible in IM 7 to do it all in one command line with more advances syntax.
plantmann
Posts: 5
Joined: 2016-08-14T16:18:58-07:00
Authentication code: 1151

Re: combine gif with sliding text

Post by plantmann »

looks good so far, but the backround has to be a gif. and the text value has to be loaded from a txt.

Appreciate the help, thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: combine gif with sliding text

Post by fmw42 »

You can change the input to any picture you want including gif. Is your gif animated or a single image. I asked that before. What do you mean "the text has to be loaded from a txt". Do you mean from a text file? If so, you can replace the text I used "testing" with "@filename.txt" where filename.txt is a text file with the text in it. If it is more than one line, then other adjustments need to be made. So again, please provide your input gif image and your text file.
plantmann
Posts: 5
Joined: 2016-08-14T16:18:58-07:00
Authentication code: 1151

Re: combine gif with sliding text

Post by plantmann »

i told you already "gif animation + sliding watermark/text overlay."
pretty clear that the text is a seperate animation + i showed you a gif as example ^^

I tried to change the jpg and replace it, didnt work out thou, the backround gif was moving weirdly and the text didnt move at all, as if the text motion was applied to the backround gif.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: combine gif with sliding text

Post by fmw42 »

No it was not clear. If your starting gif is an animation and you have an animation for the text (or you need to create one), the commands are quite different. Is your text an animation or just a text file of the text to use. How many frames in your input gif animation?

See http://www.imagemagick.org/Usage/anim_mods/

So you either need to separate the frames of your animated gif and apply the text in the correct location on each frame and then recombine as a new animation or you need to make an animation with the same number of frames for your text as images with transparent background and then merge animations. See the link above.

So again, please provide your input gif image and your text file. It would be better to know exactly what you have rather than keep making assumptions since your description of what you want has not been clear to me. Then we can show you how to do it on your data.
plantmann
Posts: 5
Joined: 2016-08-14T16:18:58-07:00
Authentication code: 1151

Re: combine gif with sliding text

Post by plantmann »

400 frames gif + txt (not animated)

I see,
the seperation and merging afterwards of all gif frames worked great, so i guess i will just experiment the rest on my own. (fine-tuning)
I wish you a good day & thank you for your help :)
Post Reply