Resizing images based on shortest side...
Posted: 2012-01-24T16:07:59-07:00
Hello:
I am a user of IM, currently on 6.3.5-q16 although I have tried solving my issue by using 6.7.4-q16 to no avail. I am using Windows Server2003, Apache and PHP 5.3.x.
A website I am writing needs to create square thumbnails of 140x140px from uploaded images.
The uploaded images may be portrait or landscape, and have varying aspect ratios.
I am trying to find a reliable way of creating a thumbnail from the uploaded image. Currently I use:
convert... -thumbnail 210x -gravity center -crop 140x140+0+0
this works reasonably well but fails when a wide landscape image is uploaded. in this case the resulting thumbnail is not square.
also the thumbnails appear a bit 'zoomed in' and do not really show off the image content too well.
I have tried using commands such as:
convert... -thumbnail 140^> -gravity center -crop 140x140+0+0
the idea being to initially create a thumbnail that is at least 140px along its smallest side (?), then crop the long side/middle part to create the square thumbnail.
but this does not work - on either 6.3.5 or 6.7.4 - i still get a non-square thumbnail on wide uploaded images.
in summary, how do i create a square thumbnail based on resizing the shortest side of an uploaded image?? obviously preserving the aspect ratio.
can anyone advise if this is possible, and give me some commands that will do this??
any information is welcome. thank you.
tim ecott.
I am a user of IM, currently on 6.3.5-q16 although I have tried solving my issue by using 6.7.4-q16 to no avail. I am using Windows Server2003, Apache and PHP 5.3.x.
A website I am writing needs to create square thumbnails of 140x140px from uploaded images.
The uploaded images may be portrait or landscape, and have varying aspect ratios.
I am trying to find a reliable way of creating a thumbnail from the uploaded image. Currently I use:
convert... -thumbnail 210x -gravity center -crop 140x140+0+0
this works reasonably well but fails when a wide landscape image is uploaded. in this case the resulting thumbnail is not square.
also the thumbnails appear a bit 'zoomed in' and do not really show off the image content too well.
I have tried using commands such as:
convert... -thumbnail 140^> -gravity center -crop 140x140+0+0
the idea being to initially create a thumbnail that is at least 140px along its smallest side (?), then crop the long side/middle part to create the square thumbnail.
but this does not work - on either 6.3.5 or 6.7.4 - i still get a non-square thumbnail on wide uploaded images.
in summary, how do i create a square thumbnail based on resizing the shortest side of an uploaded image?? obviously preserving the aspect ratio.
can anyone advise if this is possible, and give me some commands that will do this??
any information is welcome. thank you.
tim ecott.