[SOLVED] How do I add a caption to a cartoon automated-ly?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a jpeg file, I want to add text to the bottom from the command line (i.e., without opening the jpeg with an app and adding the text by hand). I have tried using ImageMagick's convert or montage, their caption and annotate commands, but they don't work. I can turn the text into a gif with text2gif, that into a jpeg with ImageMagick's convert, and join them side-by-side with ImageMagick's adjoin command, but I want it beneath.
For those interested in the motivation, I wrote a script that fetches the 'New Yorker's cartoon-of-the-day and its caption. It'd be funnier if I could join them.
"-annotate" to write text on top of an existing image.
"-append" to join your images vertically
I regularly use -annotate, I've a script on a server that uses incrontab to automatically add text over the bottom left of any image that's uploaded in to a specific folder.
Thanks! I missed -append ; I didn't see that -annotate didn't work because the text was so small and I was looking at the bottom. I need to magnify the caption's text
From memory with annotate it can take a % value so that the text scales with the image. Theres also a "gravity" option so that southwest is the bottom left hand corner for positioning.
From memory with annotate it can take a % value so that the text scales with the image.
I haven't figured out how to make that work. I read /usr/doc/ImageMagick on command-line-processing (what I should have done in the first place): it doesn't mention this in the annotate section.
Quote:
Originally Posted by TenTenths
Theres also a "gravity" option so that southwest is the bottom left hand corner for positioning.
Thanks. I hadn't noticed 'gravity'. It's a big help.
convert -gravity south -draw "scale 2,2 text 0,0 '$Caption'" input.jpeg output.jpeg
magnifies $Caption by 2, appends it to the middle of the bottom of the screen, offset by nothing.
I joined the GraphicsMagick forum; one of the maintainers informed me
Quote:
you need to do your scaling request first
(which explained why my attempts to use 'scale' after 'text' failed) and
Quote:
My experience has been that using anything other than 0,0 as the text placement coordinate does not work well in a scaled coordinate system. Using a 'translate x,y' request before the text command to change the underlying coordinate referenced by 0,0 has proven to be more reliable.
, which addressed a problem I didn't have but is useful to know if I have a problem it would address in the future.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.