creating square thumbnails regardless of picture ratio.

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
xms

creating square thumbnails regardless of picture ratio.

Post 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.
sonusdream

Post 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
xms

Post by xms »

I'll give that a go - cheers (sounds almost too easy tho :p)
xms

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

Post by anthony »

See IM examples, Thumbnails.
You can either pad out the image, or chop off the offending edges.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: creating square thumbnails regardless of picture ratio.

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

Re: creating square thumbnails regardless of picture ratio.

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: creating square thumbnails regardless of picture ratio.

Post 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.
Post Reply