LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 07-06-2017, 04:14 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,571

Rep: Reputation: 249Reputation: 249Reputation: 249
How do I add a caption to a cartoon automated-ly?


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.
 
Old 07-07-2017, 09:02 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,185

Rep: Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377
"-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.
 
1 members found this post helpful.
Old 07-08-2017, 09:31 AM   #3
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,571

Original Poster
Rep: Reputation: 249Reputation: 249Reputation: 249
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
 
Old 07-08-2017, 10:45 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,185

Rep: Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377Reputation: 1377
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.
 
1 members found this post helpful.
Old 07-09-2017, 12:19 AM   #5
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,571

Original Poster
Rep: Reputation: 249Reputation: 249Reputation: 249
Quote:
Originally Posted by TenTenths View Post
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 View Post
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.
 
Old 07-09-2017, 11:02 AM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,571

Original Poster
Rep: Reputation: 249Reputation: 249Reputation: 249
Quote:
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.

And a lot more than I asked for https://sourceforge.net/p/graphicsma...read/f307c74c/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Fotoxx 16.02 Open Source Image Editor Released with Cartoon Effect, More LXer Syndicated Linux News 1 02-02-2016 07:53 PM
Buoh cartoon reader nigelc Mandriva 1 05-04-2010 08:25 PM
LXer: Dear Linux, We Own You (cartoon) LXer Syndicated Linux News 0 04-04-2010 03:30 AM
LXer: Windows Vista's Problems Explained In One Simple Cartoon LXer Syndicated Linux News 0 09-12-2008 01:11 AM
Cartoon software? ezuli Linux - Software 6 01-21-2006 09:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration