[magick-users] RE: Thumbnails with center auto crop

Fred Weinhaus fmw at alink.net
Sat Feb 16 17:00:49 PST 2008


Use the ^ feature in -resize (presumably in thumbnail also) to resize 
the minimum dimension in your image to either 180 if the minimum 
dimension is the height or 130 if the minimum dimension is the width. 
Then crop the center 180x130 using -gravity center. The only issue is 
if the resizing will produce enough image in the larger dimension to 
fill your 180x130. That depends upon the aspect ratio of your input 
image. So my above technique would fail for square images, for then 
you would need to resize to 180 rather than as defined above. Thus 
you really need to determine the aspect ratio of your image and then 
scale appropriately to one or the other dimension of 180 or 130.  I 
suspect that this will require some scripting.



>Hi there,
>
>I have a quick issue regarding cropping and centering images. I apologise if
>this seems simple, but the question is can I do this without scripting and
>if so how exactly?
>
>I have a range of images:
>
>http://photos.vfxy.com/themes/images/72008/1.jpg
>http://photos.vfxy.com/themes/images/72008/2.jpg
>http://photos.vfxy.com/themes/images/72008/9.jpg
>
>I don't expect any images less than 200x200 total resolution. I'm looking to
>generate a 180x130 thumbnail for each image, but the command I'm using now:
>
>convert {$tname}! -filter Lanczos -thumbnail '180x130>' {$tname}m.jpg
>
>Retains the aspect ratio, of course. I'm trying to find a way to determine
>the maximum crop size in the center of the image and reduce the image to the
>180x130 without distorting it. I realize that this is kind of crappy
>considering that the user doesn't have the option to directly specify the
>crop zone...but I need something temporarily to create an auto crop of the
>image.
>
>I was looking at the documentation and there's some options like using %
>crops, but the image size is always different, so I'm not quite sure. My
>best guess would be to define a crop then use gravity to center the image,
>produce a draft crop version then reduce that aspect ratio-ed version.


More information about the Magick-users mailing list