在Centos Linux上使用ImageMagick创建半透明PNG [英] Creating a semi-transparent PNG with ImageMagick on Centos Linux

查看:656
本文介绍了在Centos Linux上使用ImageMagick创建半透明PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PNG文件,我想将整个图像转换为半透明。该图像将在KML文件中作为图标叠加层引用,以便在Google地球/地图中使用。

I have PNG files that I would like to convert the whole image to be semi-transparent. The image will be referenced in a KML file as an icon overlay for use in Google Earth/Maps.

以下示例已使用ImageMagick convert命令向我建议,但似乎都不起作用。第一个示例导致错误,第二个示例无法对图像进行任何可观察的更改。

The following examples have been suggested to me using the ImageMagick convert command, however neither seems to work. The first example results in an error, the second example fails to make any observable change to the image.

$ /usr/local/bin/convert 121112142121.png -channel Alpha -evaluate Set 50% 2121112142121.png
convert: no decode delegate for this image format '121112142121.png' @ error/constitute.c/ReadImage/550.
convert: option requires an argument '-evaluate' @ error/convert.c/ConvertImageCommand/1400.

第二种建议方法如下:

convert filename.png -fill '#00000080' -draw 'matte 100,100 reset' output.png

虽然我可以在网上找到许多用于从特定颜色或alpha蒙版创建完全透明图像的示例,但我似乎找不到任何可用于创建半透明图像的工作图片。我想用convert命令或ImageMagick Perl找到一种方法。

While I can find many examples on the web for creating fully transparent images from specific colors or alpha masks, I cannot seem to find any that work for creating semi-transparent images. I would like to find a way to do this with the convert command, or with ImageMagick Perl.

ImageMagick版本为6.8.0-4。

ImageMagick version is 6.8.0-4.

推荐答案

分辨率已找到:

convert input.png -alpha set -channel A -evaluate set 50% output.png

上述命令使整个图像(所有颜色)都是半透明的。

The above command makes the entire image (all colors) semi-transparent.

我遇到的另一个问题是ImageMagick的最新版本是从源代码编译的,没有安装所有最新的图像库(特别是libpng)。密切关注configure的输出,以确保从源代码编译时找到libpng。似乎早于6.6的ImageMagick版本和/或旧版本的libpng可能不支持透明png生成。

Another problem I had was that the latest version of ImageMagick was compiled from source without all the most recent image libraries installed (in particular libpng). Pay close attention to the output of configure to ensure libpng is found if compiling from source. It also appears that versions of ImageMagick earlier than 6.6 and/or older versions of libpng may not support transparent png generation.

这篇关于在Centos Linux上使用ImageMagick创建半透明PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆