Adding wording to pictures create PDF

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
jjrowan
Posts: 2
Joined: 2015-07-21T10:28:05-07:00
Authentication code: 1151

Adding wording to pictures create PDF

Post by jjrowan »

I have a couple of pictures that a friend asked me to add several lines of information on the picture.
I tried using convert and montage neither achieve the desired results.

I googled it and some of the suggestions were to use annotate but that option generates an error.

I've tried

cat filename.txt | convert picturename.jpg @- outputname.pdf
this results in convert: Unable to open file (-) [No such file or directory].

using montage
cat filename.txt | convert picturename.jpg -comment @- outputname.pdf
generates a fuzzy image with unreadable yellow text.

the filename.txt file has parenthesis and double quotes in it.

I'm trying to have the picture and several lines of text describing the picture below left justified.

Help appreciated.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adding wording to pictures create PDF

Post by snibgo »

For many methods of writing text on an image, see http://www.imagemagick.org/Usage/text/
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: Adding wording to pictures create PDF

Post by fmw42 »

cat filename.txt | convert picturename.jpg @- outputname.pdf
You did not tell convert how to add the text, i.e. what command to use to process the text such as -annotate.

Assuming you want to add text over the image, try
cat filename.txt | convert picturename.jpg -gravity southwest -annotate +0+0 "@-" outputname.pdf
or better
convert picturename.jpg -gravity southwest -annotate +0+0 "@filename.txt" outputname.pdf
Modify the gravity and +X+Y offsets as desired for placement. Add -undercolor somecolor if you want a color under the text for readability.

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


If you want to append text below the image, then you need a different approach. See http://www.imagemagick.org/Usage/annotating/

Or use montage label and -tile 1x1, see http://www.imagemagick.org/Usage/montage/


Please post your text file and image. The text file can be copied and pasted in the Code tags with the button above. Images can be uploaded to dropbox.com and the url put here. The double quotes may be an issue and some one would have to check this out. The quotes may or may not work. They may have to be changed to single quotes.

Also please always provide your version of IM and platform, since syntax may differ between Windows and Unix. Please read the very first post at the top of the Users forum at viewtopic.php?f=1&t=9620
jjrowan
Posts: 2
Joined: 2015-07-21T10:28:05-07:00
Authentication code: 1151

Re: Adding wording to pictures create PDF

Post by jjrowan »

I tried you examples and found my problem. I'm trying to use very old version on my Red Hat 6 server.
Version: @(#)ImageMagick 5.4.7 07/01/02 Q:16 http://www.imagemagick.org
Copyright: Copyright (C) 2002 ImageMagick Studio LLC

Moved to my Pidora server running on Raspberry Pi B. 700Mhz ARM processor significantly slower than quad processor RH 6 machine, took three minutes. Text is there but too small to read. Have to read up on how to increase size.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adding wording to pictures create PDF

Post by fmw42 »

Yes, IM 5.4.7 is ancient and syntax is different now in IM 6. You should upgrade if you can. See http://www.imagemagick.org/Usage/basics/#why


To increase text size, specify -pointsize and I would recommend you also specify the -font. But you can take the default font, if you want, but it might be different on different systems.
Post Reply