Page 1 of 1
Portrait images to landscape thumbnails...
Posted: 2007-06-26T17:46:56-07:00
by cgm225
I am new to ImageMagick, and had a question about the best way to create a landscape thumbnail from an image that is portrait in orientation.
Let me clarify. I have a web gallery that I only want to have landscape thumbnails on the
main page. However, I use my camera such that I have two types of pictures, some taken in portrait and others in landscape.
Currently, I convert the landscape photos to landscape thumbnails using the following command:
convert landscape_image.jpg -resize 250x -quality 100 landscape_thumbnail.jpg
However, now I want to convert portrait images to a landscape thumbnail (using resize and crop), but wanted to get opinions on how best to do this so that these thumbnails will look the same in dimension as those generated from landscape images.
Thank you all so much in advance!
Sincerely,
cgm225
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:04:04-07:00
by anthony
Do yu want to rotate the image, fit the image into a landscape thumbnail, or cut off the excess image to fit it into that thumbnail?
All these are showing in IM examples, thumbnails.
http://www.imagemagick.org/Usage/thumbnails/
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:07:11-07:00
by cgm225
The third option.. I want to cut off the excess image to fit it into that thumbnail I do NOT want to rotate the image, or skew the image into the landscape thumbnail size.
I will look at that link now, but could you help me figure this out by posting an example here?
Regardless, thank you for your help!
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:13:47-07:00
by anthony
It is there...
http://www.imagemagick.org/Usage/thumbnails/#cut
There is a suggestion that perhaps IM should include a
-resize-crop option to resize and crop an image to best fit the given space, rather than try to fit the whole image into the space given (the default).
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:20:36-07:00
by cgm225
Ok, final question, in that example, the image is cropped to 100x100. However, in my question, I only want to specify the width of the thumbnail (250px) and not the height. That way, for photos taken on different cameras with different baseline dimensions, the convert command will keep the image's aspect ratio.
However, when going from a portrait image to landscape thumbnail, I am going to need to specify both numbers for the cropping action. Therefore, is there a way to have ImageMagick first rotate the portrait image somehow, and calculate what the thumbnail height is going to be in light of a specified 250px thumbnail width, and then rotate it back, and then crop?
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:26:45-07:00
by anthony
Oh that is easier.
resize directly to 250x The 999 is just a limit in case you have a very tall image.
Then center crop the image to the maximum height desired EG
Code: Select all
convert image -thumbnail 250x \
-gravity center -crop 250x200+0+0 +repage output_image
If the image was landscape and not that high, then the crop will cover the whole image and output the original image unchanged.
Basically I demonstrated that on the thumbnail pages but for a fixed height, rather than a fixed width.
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:37:04-07:00
by cgm225
Where is that absolute 200px in the cropping command coming from?
Let me restate my question in more simpler terms, because I am probably not articulating myself well.. sorry!
I want to resize (and crop if necessary) all landscape or portrait photos all into landscape thumbnails that all have the same dimensions, and with the same IM command (of course, with different file names). Is that possible?
I need this command to be flexible so that I can use it on photos taken with different cameras (such that the starting width:height ratio may be different).
Thanks again for the help!!
Re: Portrait images to landscape thumbnails...
Posted: 2007-06-26T18:40:17-07:00
by anthony
If you want the width to always be the same, and crop just the height the previous one will do the job. However for 'panoramic' images whci hwas VERY VERY wide, you may have to crop sides instaed. In whcih case the original 'crop to fit' method is better.