PerlMagick equivalent of "+map," remove Local Color Tables?
PerlMagick equivalent of "+map," remove Local Color Tables?
I have a script that regularly churns out a bunch of animated GIFs, which, because of the software toolchain on the other end, absolutely cannot have local color tables. Right now I'm saving the animations with their local color tables, then using the "+map" command-line option to convert them out - but I'm pretty sure that doing this in pure PerlMagick, and eliminating the need to Write a temporary image, would save me some processing time (which I can't get enough of).
Problem is I can't figure a way to make this happen. I've tried various permutations of variable sets, the Quantize() function, and some dithering stuff to defeat local color tables from within PerlMagick, but nothing works.
So,
Is there a PerlMagick equivalent to the +map option? (I can't find anything in the PerlMagick docs about wholesale colormap operations like -/+map) Alternatively, does anyone know of another method to remove local color tables from an animated GIF using PerlMagick?
Any input appreciated, thanks!
Problem is I can't figure a way to make this happen. I've tried various permutations of variable sets, the Quantize() function, and some dithering stuff to defeat local color tables from within PerlMagick, but nothing works.
So,
Is there a PerlMagick equivalent to the +map option? (I can't find anything in the PerlMagick docs about wholesale colormap operations like -/+map) Alternatively, does anyone know of another method to remove local color tables from an animated GIF using PerlMagick?
Any input appreciated, thanks!
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Try the Remap() PerlMagick method to generate a global colormap.
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
That sounds like the right track for me to be on, but I still can't figure out how to use it.
I don't see any mention of Remap() in my installed perldoc page or on http://www.imagemagick.org/script/perl-magick.php - is there somewhere else I can look for documentation on PerlMagick Remap?
I don't see any mention of Remap() in my installed perldoc page or on http://www.imagemagick.org/script/perl-magick.php - is there somewhere else I can look for documentation on PerlMagick Remap?
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
We will update the PerlMagick's web page with Remap() by sometime tomorrow. Another option is to use Map() or Quantize() with the global => 'true' option.
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Thanks for that tip. Using Remap with some arbitrary palette image (http://www.imagemagick.org/Usage/quantize/netscape.gif for instance) is successfully dithering my GIF frames, though it still isn't removing my local color table entries according to giftrans.
I don't think it much matters though, because now the dithering itself is taking more CPU time than when I save an intermediate file and use `convert ... +map ...`. I don't suppose there is a way to harness some faster color-mapping method from within PerlMagick? Otherwise it looks like +map is the best I'm going to be able to get.
I don't think it much matters though, because now the dithering itself is taking more CPU time than when I save an intermediate file and use `convert ... +map ...`. I don't suppose there is a way to harness some faster color-mapping method from within PerlMagick? Otherwise it looks like +map is the best I'm going to be able to get.
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
I've been experimenting with this a little more, and I think I may have hit upon the source of my problem.
If I set each frame of my animation to type => "Palette" (per tip from http://www.imagemagick.org/Usage/quantize/#map_common) in PerlMagick, then use Remap(), the local color tables are gone. But the transparency in my animation frames is replaced with black.
Contrarily, if I set the frames to type => "PaletteMatte" - or, after setting to type Palette, use Transparent() to re-transparify the black - local color tables remain, despite the Remap().
It looks like the transparent color is getting in the way of PerlMagick successfully merging the colormaps. But the +map operator is able to handle transparency just fine. Is there a way to work around this?
If I set each frame of my animation to type => "Palette" (per tip from http://www.imagemagick.org/Usage/quantize/#map_common) in PerlMagick, then use Remap(), the local color tables are gone. But the transparency in my animation frames is replaced with black.
Contrarily, if I set the frames to type => "PaletteMatte" - or, after setting to type Palette, use Transparent() to re-transparify the black - local color tables remain, despite the Remap().
It looks like the transparent color is getting in the way of PerlMagick successfully merging the colormaps. But the +map operator is able to handle transparency just fine. Is there a way to work around this?
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Hi there,
does anyone know if there is there a way to *prevent* dithering when calling Remap() -- and is willing to share this information with me?
Thanx --
tcrass
does anyone know if there is there a way to *prevent* dithering when calling Remap() -- and is willing to share this information with me?
Thanx --
tcrass
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Remap() has a dither-method option. Use "None" to not dither the results.
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Ah, thanks! But this is not yet documented on http://www.imagemagick.org/script/perl-magick.php, is it?magick wrote:Remap() has a dither-method option. Use "None" to not dither the results.
Regards --
tcrass
[EDIT] Hmm... seems not to work. The following piece of code outputs a dithered image (error handling omitted):
Code: Select all
my $img = Image::Magick->new();
$img->Read('some_image.png');
my $map = Image::Magick->new();
$map->Read('some_palette.png');
$img->Remap(image => $map, 'dither-method' => 'none');
$img->Write('remapped.png');
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
We can reproduce the problem you posted and will have a patch available by sometime tomorrow. You'll need to set the new 'dither' option to 'false' to prevent Remap() from dithering its results.
Re: PerlMagick equivalent of "+map," remove Local Color Tables?
Great!magick wrote:We can reproduce the problem you posted and will have a patch available by sometime tomorrow.
Thanx --
tcrass