Separating each color in an animated gif into separate gifs

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
naive
Posts: 9
Joined: 2018-04-26T23:53:58-07:00
Authentication code: 1152

Separating each color in an animated gif into separate gifs

Post by naive »

Hey guys I'm trying to separate a colored animated gif into different color files (each color in a gif should become a new gif only with that color and the rest would be transparent) so i could later bitmap each of those files to give it a bit more sharpness and maybe reduce the size. Could someone advice on how could i do that?
I've tried Fred's kmeans script but to no awail, as i only get the color values

Image



Working environment:
IM version:
Version: ImageMagick 7.0.8-26 Q16 x86_64 2019-02-09 https://imagemagick.org
OS:
Mac OS 10.12.6 (Sierra)

Thanks in advance!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Separating each color in an animated gif into separate gifs

Post by fmw42 »

You will have to extract each frame one at a time, then for each color make all the other colors transparent using +transparent somecolor and write that to a new image. That means for each frame you will get up to 256 new images. Is that what you want? To do that, you will have to write a script loop over each of the 11 frames (after coalescing) and over each color in that frame. That will be quite a few images. You can get the list of colors using -unique-colors.

See
https://imagemagick.org/script/command- ... ransparent
https://imagemagick.org/Usage/quantize/#extract

You can reduce the size of the animation, by applying one single color map to all frames. See -remap at

https://imagemagick.org/Usage/quantize/#remap

use -dither none
Post Reply