“ImageMagick”的版本间的差异

来自wrc's Wiki
跳到导航 跳到搜索
第26行: 第26行:
 
=== 将透明部分变为某个颜色 ===
 
=== 将透明部分变为某个颜色 ===
  
<ref>https://superuser.com/a/214023</ref>
+
<ref>[https://superuser.com/a/214023 Using ImageMagick, how do I replace transparency with a fill colour?]</ref>
  
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
第34行: 第34行:
 
=== 只允许几种颜色 ===
 
=== 只允许几种颜色 ===
  
<ref>https://stackoverflow.com/a/55965617/10974106</ref>
+
<ref>[https://stackoverflow.com/a/55965617/10974106 Process image with Imagemagick to “default palette” (for example 16 or 256 colours)]</ref>
  
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>

2021年5月13日 (四) 04:15的版本

ImageMagick 是一个图像处理工具。

例子

转换格式

convert input.png output.jpg

剪裁

convert -crop 800x600+10+10 input.png output.png

剪裁白色区域

convert input.png -trim output.png

将白色区域变为透明

convert input.png -transparent white output.png

将外侧的白色区域变为透明

convert input.png -fill none -draw 'color 1,1 floodfill' output.png

将透明部分变为某个颜色

[1]

convert input.png -background '#51c3c5' -mosaic output.png

只允许几种颜色

[2]

convert 'xc:#50c1c3' 'xc:#323232' 'xc:#f4891e' 'xc:#efefef' xc:'rgba(0,0,0,0)' +append palette.gif
convert input.png +dither -remap palette.gif output.png

参考资料