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 mi开发者_如何转开发ssing something?
test input:
Result:
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
(source: datageist.com)
I don't know if that helps, but it seems to work.
Updated the convert.exe with the latest release from www.imagemagick.org and...tada! problem solved.
精彩评论