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
Portrait images to landscape thumbnails...
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Portrait images to landscape thumbnails...
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/
All these are showing in IM examples, thumbnails.
http://www.imagemagick.org/Usage/thumbnails/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Portrait images to landscape thumbnails...
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!
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!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Portrait images to landscape thumbnails...
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).
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).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Portrait images to landscape thumbnails...
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?
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?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Portrait images to landscape thumbnails...
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
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.
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
Basically I demonstrated that on the thumbnail pages but for a fixed height, rather than a fixed width.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Portrait images to landscape thumbnails...
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!!
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!!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Portrait images to landscape thumbnails...
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/