首页 > 解决方案 > Transparency on Imagemagick

问题描述

I'm using this code wrote on ImageMagick, but I want this background:

Img 1

In order to match the color of my terminal, which is #000 with 70% opacity. If I leave it without background, it just goes completely transparent:

Img 2

And no matter what I do, it doesn't works or it makes the image missing. I've searched through the ImageMagick code on forums and here on StackOverflow, but I couldnt make it work.

标签: imageimagemagicktransparencyopacityimagemagick-convert

解决方案


在 ImageMagick 中,要获得不透明度为 70% 的 #000 或黑色或 rgb(0,0,0),请使用

"rgba(0,0,0,0.7)"

或最接近的十六进制值是

#000000b3

所以你的转换命令应该是:

convert input.suffix -resize 300x -gravity center -background "rgba(0,0,0,0.7)" -extent 1100x400 output.png


不要保存为 JPG,因为它不支持透明度。

如果在类 Unix 系统上或在逗号之间放置空格,请保留引号。


推荐阅读