gravity center not working with IM 6.2.8

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
vostok
Posts: 1
Joined: 2012-02-21T09:07:29-07:00
Authentication code: 8675308

gravity center not working with IM 6.2.8

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: gravity center not working with IM 6.2.8

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: gravity center not working with IM 6.2.8

Post 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 :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply