Why can't I add text into a JPEG file?

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
engtia

Why can't I add text into a JPEG file?

Post by engtia »

C:\im>convert -draw 'text "test"' winter.jpg winter8.jpg
convert: unable to open image `test'': No such file or directory.
convert: Non-conforming drawing primitive definition `text'.

Hi guys, just started in IM. Hit some stopper. I think this is rather simple but I am unable to solve it. I am merely trying to add text(which is "test") into the image. I am running in windows xp. Help me please! Thanks a milliion!

Tung
vikrammandal

Re: Why can't I add text into a JPEG file?

Post by vikrammandal »

This worked for me

mogrify -pointsize 20 -draw "fill red text 10,10 'my text' " winter.jpg
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Why can't I add text into a JPEG file?

Post by el_supremo »

There are three problems with your command.

First, the quotes are tripping you up. Windows does not like the single quote. Use double quotes as the outermost pair on a string, like this: "text 'test'"
Note that the string ends with a single quote and then a double quote.

Second, as an argument to the text subcommand, you have to specify a coordinate where the text will be placed. e.g. "text 10,10 'test'"

Third, you must read the image in first before you try to draw on it. So, the whole command should be:

Code: Select all

convert winter.jpg -draw "text 10,10 'test'" winter8.jpg
[EDIT] vikrammandal's example of the mogrify command will work but it overwrites the winter.jpg input image. This is fine if that's what you want to do, but otherwise you should use the convert command to produce a different output file.
Pete
engtia

Re: Why can't I add text into a JPEG file?

Post by engtia »

thank you so much for the prompt reply. I wonder why convert don't work?
engtia

Re: Why can't I add text into a JPEG file?

Post by engtia »

Thanks Vikrammandal and Pete! Your solve my problem nicely. Now I know both methods. I must have been referred to a sample meant for Unix. The quotes used are different. Thanks!
Post Reply