Imagemagick旋转透明图像上不需要的黑色背景 [英] Imagemagick unwanted black background on rotated transparent images

查看:279
本文介绍了Imagemagick旋转透明图像上不需要的黑色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站可以生成彼此以不同角度堆叠的类似宝丽来的图像。
到目前为止一切运行良好,但现在我已经开始在透明的.png周围获得一些黑色背景。

你可以看到问题这里。上一张专辑中的图片都搞砸了。

I have a website that generates polaroid-like images stacked on eachother at different angles. Up until now everything worked well, but now i've started getting some black background around my transparent .png's.
You can see the problem here. The images in the last album are all messed up.

我正在使用imagemagick(6.5.4.7-3.fc12)。

I'm using imagemagick (6.5.4.7-3.fc12).

我的命令看起来像这样:

第一个包含在foreach中并生成一堆以不同角度旋转的png

转换'{$ sf}'-auto-orient -thumbnail 120x120 -gravity center -bordercolor snow -background black -polaroid {$ angle} {$ i} .png

my commands look something like this:
the first one is contained whitin a foreach and generates a bunch of pngs rotated at different angles
convert '{$sf}' -auto-orient -thumbnail 120x120 -gravity center -bordercolor snow -background black -polaroid {$angle} {$i}.png

第二个命令采用先前生成的图像并将它们堆叠起来


转换'* .png' - 背景透明-alpha on -gravity center -layers merge -extent 190x190 + repage -thumbnail 115x115 -gravity center -extent 120x120'rend.png'

the second command takes the previously generated images and stacks them toghater
convert '*.png' -background transparent -alpha on -gravity center -layers merge -extent 190x190 +repage -thumbnail 115x115 -gravity center -extent 120x120 'result.png'

据我所知,黑色背景已存在于使用第一个命令生成的图像中,它们仅在我旋转图像时出现。如果我只使用 -polaroid 0 而不是 + polaroid ,那么结果图像就可以了。

我的猜测是问题不在于代码本身,而是在我的服务器上升级了ImageMagick或者其他东西,这开始了整个混乱。

As far as I got with the debuging, the black background is already present in the images generated with the first command and they only appear when I rotate the images. If I only use -polaroid 0 instead of the +polaroid, then the resulting images are ok.
My guess is that the problem is not with the code itself, but rather ImageMagick or something else got upgraded on my server and that started this whole mess.

I还设置了各种组合设置 -alpha 以及我在imagemagick文档中找到的所有其他内容,甚至只是与透明度略有关系,但似乎没有任何效果。

I also tried all kinds of combinations with setting -alpha and everything else i could find in the imagemagick docs that is even just slightly related to transparency, but nothing seems to work.

推荐答案

经过各种测试后我终于得出结论,问题不在于我的转换命令。

After all sorts of testing I finally got to the conclusion that the problem was not with my convert commands.

我的问题的解决方案是重新安装/更新ImageMagick。

The solution to my problem was to reinstall/update ImageMagick.

这篇关于Imagemagick旋转透明图像上不需要的黑色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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