tags:

views:

278

answers:

2

I'm trying to create a process to automatically generate thumbnails of the images uploaded to my website.

I'm using this command line:

-thumbnail "120x90>" -quality 95 -background transparent -gravity Center -extent 120x90 img.png

The thumbnail is generated without problems, with the correct aspect ratio. but the option -gravity center seems that is doing nothing, the actual image is always aligned to the left of the canvas, when i want it centered...Am i missing something?

test input:

alt text

Result:

alt text

+1  A: 

If your source images have a similar aspect ratio to your thumbnails, there may be nothing to crop, and that's why it doesn't seem like -gravity is having any effect. For example, if you change -extent to 50x50, then play with -gravity, you'll see changes in the alignment.

Edit (update for comments):

Here's the result I got using this command-line with your sample image:

convert.exe -thumbnail "120x90>" -quality 95 -background transparent -gravity Center -extent 120x90 monalisa171p.jpg monalisa171p_thumb.jpg

alt text

I don't know if that helps, but it seems to work.

datageist
I'm using a 337x500px image for testing. The result is a 120x90 px image with all the right-side filled with blank pixels. The entire image is a aligned to left.
Drevak
updated with and example. You will see that the image is not centered on the canvas, but aligned to the left.
Drevak
A: 

Updated the convert.exe with the latest release from www.imagemagick.org and...tada! problem solved.

Drevak
Great! Glad to hear you got it working.
datageist