简体   繁体   English

PHP ImageMagick在每帧中更改颜色GIF动画

[英]PHP ImageMagick change color in every frame Animated Gif

I am trying to change RGB values in an animated GIF to another RGB value. 我正在尝试将动画GIF中的RGB值更改为另一个RGB值。 However in all my attempts it's only changing the color in one frame instead of all frames. 但是,在我所有的尝试中,它只是在一帧而不是所有帧中更改颜色。

$imgif = new Imagick(HOME_PATH.'/images/6.gif');
$target = 'rgba(238,131,41, 1.0)';
$fill = 'rgba(163,145,144, 1.0)';
$fuzz = 0.05 * $imgif->getQuantumRange()['quantumRangeLong'];
$imgif->opaquePaintImage($target, $fill, $fuzz, false, Imagick::CHANNEL_DEFAULT);

$imgifblob = $imgif->getImagesBlob();

Is there anyway to index a color for the entire GIF and change it? 无论如何,是否有索引整个GIF的颜色并对其进行更改? I am rather lost as I don't have much experience with image manipulation. 我不知所措,因为我对图像处理没有太多经验。

Sorry, I do not know Imagick that well. 抱歉,我不太了解Imagick。 But here is how to do it in Imagemagick command line. 但是,这是在Imagemagick命令行中执行的方法。 You may have to loop over each frame in Imagick, since it may not allow for multi-frame images to be processing. 您可能必须在Imagick中循环浏览每个帧,因为它可能不允许处理多帧图像。 But perhaps using readImages would work. 但是也许使用readImages可以工作。 See https://www.php.net/manual/en/imagick.readimages.php , where you specify all frames in the gif as 6.gif[0--1], which is all frames from frame 0 to the last frame -1. 请参阅https://www.php.net/manual/zh-CN/imagick.readimages.php ,在其中您将gif中的所有帧都指定为6.gif [0--1],即从帧0到最后一个的所有帧。框架-1。 Sorry, I just do not know. 对不起,我就是不知道。 An Imagick expert might be able to help further. 一位Imagick专家也许可以提供进一步的帮助。

Input: 输入:

在此处输入图片说明

convert bunny_anim.gif -coalesce -fuzz 10% -fill red -opaque "rgb(51,77,204)" -layers optimize new_bunny.gif


在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM