Why is this chop command not working

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?".
Locked
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Why is this chop command not working

Post by troyd1 »

I have done:
convert start.png -size 1000 -font arial -pointsize 24 caption:"this is a long bunch of information that want to be longer than the box" -gravity east -chop 700x0 -gravity northwest -geometry +300+100 -composite end.png

What I am trying to do is create an invisible box 300 pixels long, put text in it and truncate the text. In this example, I am left justifying it. My idea was to create a long box and then chop it.

The problem with this is that it is chopping the box as well as the original graphic.

If I do:
convert -size 1000 -font arial -pointsize 24 caption:"this is a long bunch of information that want to be longer than the box" -gravity east -chop 700x0 start.png +swap -gravity northwest -geometry +300+100 -composite end.png

it works fine, but I have this command in a series of commands.

If someone has a better way to do this or can tell me what I am doing wrong, it would be greatly appreciated.

Thanks

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Why is this chop command not working

Post by fmw42 »

I am not sure I understand. What is the image start.png? Why do you need it if you are just trying to make a transparent background 300 pixels long and put text into it?

Try this:

convert -size 300x300 xc:none -fill skyblue -gravity West -pointsize 48 -font Arial -annotate +0+0 "this is some very long text that you want to put into a small box" -background none -trim tmp.png

This will result in a 300x35 pixel transparent image with skyblue text starting with the word "this" and ending where it gets cutoff by 300 pixels and trimmed to minimum height.

troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: Why is this chop command not working

Post by troyd1 »

Sorry I did not give more detail. The image start.png is a large image 1820x910. I want to place text on it. I do not want the text to wrap and want to be able to specify a font and font size. I have an application wrapped around this so I am executing the command line to build this image. I am doing multiple iterations of the caption, chop and composite to keep adding text to the image. I just took this code out as an example which during test was basic enough and I could still get it to fail. If I take out the chop code, it works perfectly, except it wraps if it gets too long and I want it to truncate instead.

troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: Why is this chop command not working

Post by troyd1 »

Also, if your solution will still work, please show me how I can start with the start.png and do 2 of the annotations that you suggested.

Thanks

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Why is this chop command not working

Post by fmw42 »

I have not tested this, but try

convert start.png \
\( convert -size 300x300 xc:none -fill skyblue -gravity West -pointsize 48 -font Arial -annotate +0+0 "this is some very long text that you want to put into a small box" -background none -trim \)
-geometry +LOCX+LOCY -composite \
result.png


start.png is the background
the second part in \( ... \) creates the overlay text in a 300x? box
the third part tells you where you want to position the top left corner of the overlay text which then gets composited onto the background using transparency to make the fourth line namely result.png

You can repeat the second and third lines for adding more text.

Locked