imagemagick - 基于宽高比进行转换

时间:2013-08-21 19:48:34

标签: imagemagick aspect-ratio imagemagick-convert

我需要根据宽高比转换图像。

纵向图像需要转换为500px宽度。

横向需要转换为800px宽度。

这可以通过一个命令行实现。

我正试图解决这个问题一段时间,但找到的唯一方法是使用识别并调用相应转换的sh脚本。

1 个答案:

答案 0 :(得分:2)

如果有人正在寻找这个,这里是我如何找到天气图像是风景或肖像

a=$(identify -format "w=%w;h=%h" l.jpg)
eval $a

if [ "$w" -ge "$h" ]
then
  echo 'landscape'
else
  echo 'portrait'
fi