Page 1 of 1

gravity center not working with IM 6.2.8

Posted: 2012-02-21T09:12:52-07:00
by vostok
Hi,

I'm trying to resize a squarish image to a 320x240 image with blackish padding on the sides.

With a machine with IM 6.5.7-8 installed, this line

Code: Select all

convert original.jpg -resize 235x240 -background '#050608' -gravity center -extent 320x240 -quality 99% new.jpg
works well. However a CentOS machine with IM 6.2.8 produces a pic with the original square resized and put in the left side of the frame, as in with -gravity left.
Any ideas?

Re: gravity center not working with IM 6.2.8

Posted: 2012-02-21T10:46:24-07:00
by Bonzo
I would create a background image and put the photo onto it; a lot will have changed from 6.2.8

Code: Select all

convert -size 320x240 xc:black ( input.jpg -resize 235x240 ) -gravity center -composite -quality 99% new.jpg
xc: may not work as I do not know when that was introduced.

Re: gravity center not working with IM 6.2.8

Posted: 2012-02-21T17:34:46-07:00
by anthony
Centered composition is the best solution, it is actually what -extent is really doing after all.

-extent started to make use of -gravity in version v6.3.2 Also at that time it added the use of -background color
before that it only cleared new areas to black.

Originally -extent was added to allow FAST image size modification without image data changes. Of course that is not what it does now :-)