ImageMagick resize - set width for both landscape and portrait images

给你一囗甜甜゛ 提交于 2019-12-05 11:43:39

As discussed in the comments of the answer by JWK:

The images seem to be landscape instead of portrait. Some applications that show an image read extra information from the exif profile of the image to determine the orientation. This was causing some confusion because ImageMagick does not automatically use the information from the exif profile. This can be forced with the auto-orient option. The command should be changed to this:

convert source.jpg -auto-orient -resize 200x out.jpg

The 200x can also be written as 200 but using 200x or x200 shows better if the width or the height should be resized.

I got this solved. Turned out that the image information of my portrait source file was somehow messed up.

I ran the identify portrait_source.jpg command and noticed that it had the width and height wrong ( 4320 x 3240 instead of 3240 × 4320). So basically, ImageMagick thought it was looking at a landscape oriented file when really it was a portrait oriented file. All other programs (OSX Finder, Preview) showed the image in portrait orientation.

Simply opening the image in Preview and saving it fixed the image information and after that the resize worked as expected.

So, if you run into an issue similar to mine, make sure to check the image information on your source image. I have no idea why the information was wrong in the first place. I used a photo made with a digital camera.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!