Page 1 of 1

creating square thumbnails regardless of picture ratio.

Posted: 2007-01-17T04:59:05-07:00
by xms
Hi Guys,

I'm trying (and failing miserably) to get Imagemagick to replicate a task that I do in fireworks to create a 65x65px thumbnail image.

In fireworks I i take the original image, resize its smallest side to 65px (scaling the other side down equally so the image does not look squashed) and then i crop a 65x65px square from the centre of the image.

This essentially gives me the original image, but as a 65x65 thumbnail and keepign the ratio of the original image, but possibly with it's sides trimmed.

If that doesn't make sense let me know and i can provide some images.

Posted: 2007-01-17T07:42:57-07:00
by sonusdream
you can try using command

convert -resize 65x65! image.jpg thumbnail-output.jpg

note that there is a '!' character after the dimension.


regards,
sonus

Posted: 2007-01-17T07:50:47-07:00
by xms
I'll give that a go - cheers (sounds almost too easy tho :p)

Posted: 2007-01-17T09:17:41-07:00
by xms
I'm afraid that command didn't work.

It does create a 65x65px thumbnail, but it squashes the dimensions rather than trimming the edges to keep the correct ratio.

Posted: 2007-01-17T16:54:47-07:00
by anthony
See IM examples, Thumbnails.
You can either pad out the image, or chop off the offending edges.

Re: creating square thumbnails regardless of picture ratio.

Posted: 2007-06-24T14:33:58-07:00
by dognose
I found this command:

convert -size 300x300 hatching.jpg \
-thumbnail x200 -resize '200x<' -resize 50% \
-gravity center -crop 100x100+0+0 +repage cut_to_fit.gif

It works for landscape photos, but not portrait.

I'm tyring to find the idea "crop to square" routine. The one I currently use involves padding it out, but, I'd rather it just crop off the edges.

Re: creating square thumbnails regardless of picture ratio.

Posted: 2007-06-24T16:36:26-07:00
by anthony
It works find for me.

Though it does assume the photo has the correct orientation.
If you photo has NOT been auto-orientated add a -auto-orient before the -thumbnail operator.

Perhaps it is time a -resize-crop operator is added to IM to resize and crop and image to bebest fit the given size.

I'll add this to the 'furture proposals' page

Re: creating square thumbnails regardless of picture ratio.

Posted: 2007-06-25T06:56:24-07:00
by dognose
Oh, my mistake, it is working. I reversed one of the x200's.

It'd be great if there was a simpler way of doing this. so, I'm all for the crop resize.