0

只是匆匆忙忙。

我有一系列图像min*.png,我想将其制作成 gif 动画。

它们都是完全透明的,除了我要为该帧填充的区域上的一些白点。

有没有办法从这些创建动画,使背景是黑色的(这样白点就会出现?)

我对两者都感兴趣:

  1. 黑色背景,并将每个连续的图像粘贴到前一个图像的顶部(所以 framei是黑色背景加上所有点到 image i
  2. 每帧仅包含(黑色背景上的图像 i)

我认为 1. 我需要使用-dispose none2 我使用-dispose backgroundor -dispose previous,但实际上将背景设置为黑色的各种尝试都失败了(我花了很多时间阅读这个 imagemagick 页面,但仍在学习)。

例如

convert -background black -dispose background min*.png out.gif

各种尝试-background-dispose总是产生一个我的 gifmin*.png具有透明背景,而不是黑色的。我想我很接近,但不确定。

4

1 回答 1

1

This may be useful for the black background problem: starting from ImageMagick 6.7.5 you can remove transparency and replace it with a static color; you can read more about this command here

Hope this helps, unfortunately I have an older version of Imagemagick, so i can't try it myself

Example from ImageMagick documentation:

  convert moon.png  -background tan  -alpha remove  alpha_remove.png

The color "tan" replaces the transparent areas of the picture


Comment from mathematical.coffee

Using the above answer, I was able to generate the animations I wanted.

1: successive buildup of dots, all on a black background. Turned out to be as simple as creating a black background picture to put at the start of the animation, and using -coalesce:

# where bg.png is a black png of the appropriate size:
convert bg.png min*.png -coalesce out.gif
# in the below the first line creates the black background
#  image, same size as my first min00.png image, for me:
convert min00.png -alpha Opaque +level-colors black \
    min*.png -coalesce out.gif

2. use the method mentioned above:

convert min000*.png -background black -alpha remove out.gif

In both I was using imagemagick 6.7.something.

于 2013-05-13T08:00:21.497 回答