Imagemagick and text problems

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
whitto

Imagemagick and text problems

Post by whitto »

Hi there,

I am pretty new to imagemagick and have some problems. I don't know how to tell imagemagic that I want to have new line somewhere in my text. From input file it wouldn't be parsed.
My code:

Code: Select all

#!/bin/bash

convert -size 700x \
	-background none \
	-pointsize 45 \
	caption:@- \
	text.png
composite -compose Multiply -gravity center text.png background.jpg result.png
rm text.png
comment: background.jpg is 800x600 image and input text is parsed from file, but where there are \n characters they are not parsed on image as new lines.
How to do that?
Thanks,
Vito.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Imagemagick and text problems

Post by Bonzo »

I do not know if this will help but this is a link to some tests I have done with word wrapping - php code.

http://www.rubblewebs.co.uk/imagemagick ... d_wrap.php

The text file test is the last one and it seems to wrap OK.

http://www.rubblewebs.co.uk/imagemagick/wrap/text.txt
whitto

Re: Imagemagick and text problems

Post by whitto »

Heh, I tried your solution, but all I have is the same thing. There is no new line!
Image

This is realy strange.
Some more info about my imagemagick:
Version: ImageMagick 6.2.4 02/16/07 Q16
I am running it on xubuntu.
Any idea?
Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Imagemagick and text problems

Post by anthony »

A string argument read from a file will be read as 'literal'. That is a new line is a new line and a backslash is just a backslash. No escape codes are applied. This is on purpose as it assumes that any processing of text in a file has been done.

That is to add a new line (or paragrph break) in file text, should REALLY be a newline and not '\n'.

See IM Examples Text to Image Handling,
Special Escape Characters in Text Arguments
http://www.imagemagick.org/Usage/text/#escape_chars

So add your newline to the file!!! And make sure you IM is later than IM v6.3.3
Otherwise pay special attention to the version warning notes.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply