extent and image position

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
Marquisk2
Posts: 4
Joined: 2013-09-09T08:50:53-07:00
Authentication code: 6789

extent and image position

Post by Marquisk2 »

I'm using the command line tool and I'm trying to use extent to extend the canvas of an image in all directions. Meaning, Top, Left, Right, and Bottom.

Here is my command line text:

convert -verbose -background none -extent 480x500 -limit memory 68 -limit map 68 /location/to/file/bookmark1_6.svg /location/to/file/temp/1379205695_5.png

I've tried this to change the offset of the image as a test: convert -verbose -background none -extent 480x500+250+300 -limit memory 68 -limit map 68 /location/to/file/bookmark1_6.svg /location/to/file/temp/1379205695_5.png


I've also tried adding geometry separate like this:
convert -verbose -background none -geometry +250+300 -extent 480x500 -limit memory 68 -limit map 68 /location/to/file/bookmark1_6.svg /location/to/file/temp/1379205695_5.png

but all these do is extend the bottom of the image. I can't seem to offset the position of the original image, or use extent to add more to the canvas in different directions.

Any suggestions?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: extent and image position

Post by snibgo »

By default, your image is placed on the "North" side of the extent. You probably want the centre:

Code: Select all

convert in.svg -gravity Center -extent 480x500 out.png
Note: the proper place for gravity and extent is after the input image, not before.
snibgo's IM pages: im.snibgo.com
Marquisk2
Posts: 4
Joined: 2013-09-09T08:50:53-07:00
Authentication code: 6789

Re: extent and image position

Post by Marquisk2 »

Thanks for the quick response!

Unfortunately I tried moving the extent and gravity to after the input file like this:

convert -verbose -background none -limit memory 68 -limit map 68 /location/to/file/bookmark1_6.svg -extent 480x500 -gravity Center /location/to/file/temp/1379205695_5.png

and the image is still up top. I even tried it again with geometry with no luck. :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: extent and image position

Post by snibgo »

"-gravity" has an effect on "-extent", but only if it comes before it in the command. When placed after it, it has no effect.

As a general rule, options should be placed in their "logical" order: read an image, set an option that modifies the action of "extent", do the extent, write the image.
snibgo's IM pages: im.snibgo.com
Post Reply