如何从命令行对图像进行方形处理并使用透明垫进行填充(imagemagick) [英] How to square an image and pad with transparency from the commandline (imagemagick)
本文介绍了如何从命令行对图像进行方形处理并使用透明垫进行填充(imagemagick)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标题为方形填充或裁剪的部分介绍了一种生成方形图像的方法-对于尺寸未知的文件-并用颜色填充背景.
The section entitled Square Padding or Cropping describes a method to generate a square image--for a file whose dimensions are unknown--and pad the background with a color.
如何执行相同的操作,但是要创建透明背景.
How do I perform the same operation, but create a transparent background.
推荐答案
这些来自Anthony的示例的修改后的方法都对我有用:
These modified methods from Anthony's examples both work for me:
convert thumbnail.gif \
\( +clone -rotate 90 +clone -mosaic +level-colors grey -transparent grey \) \
+swap -gravity center -composite square_padded.gif
convert thumbnail.gif -virtual-pixel none -set option:distort:viewport \
"%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]" \
-filter point -distort SRT 0 +repage square_external.gif
这篇关于如何从命令行对图像进行方形处理并使用透明垫进行填充(imagemagick)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文