liz*_*isk 11 image imagemagick
当通过convert -rotate命令旋转图像时,图像尺寸被放大.有没有办法围绕中心旋转并保持图像大小,裁剪边缘?
Eny*_*yby 20
convert image.jpg -distort SRT -45 rotate_cropped_image.png
Run Code Online (Sandbox Code Playgroud)
见http://www.imagemagick.org/Usage/warping/#animations
例: 
另见-distort帮助:http://www.imagemagick.org/script/command-line-options.php? #distort
我在 Imagemagick 论坛上找到了这个答案:
在不知道图像的原始大小的情况下,一个简单的解决方案是使用 Alpha 复合运算符“Src”作为“裁剪到此图像大小”类型的操作。看:
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/compose/#src
例如(仅限 ImageMagick 版本 6):
convert image.jpg \( +clone -background black -rotate -45 \) \
-gravity center -compose Src -composite rotate_cropped_image.png
Run Code Online (Sandbox Code Playgroud)