Re: Importing GIF looses transparency (w/ConstituteImage)
Bob Friesenhahn <[email protected]> Thu, 15 Oct 2020 17:00:49 -0500 (CDT)
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 15 Oct 2020, [email protected] wrote: > Hello Bob, > > On Wed, 14 Oct 2020 at 18:52, Bob Friesenhahn > <[email protected]> wrote: >> Libvip's implementation of magick_import_pixels() does not appear to >> be very efficient since it is creating a temporary image. > > It's copied from this compatibility wrapper I found: > > https://sourceforge.net/p/graphicsmagick/code/ci/default/tree/wand/magick_compat.c#l315 This is likely code that I wrote. > Something quicker would be great. > > I added: > > image->matte = constitute_image->matte; > > And GM is now saving transparency! Thanks! > > It's still writing 16-bit images though. Is there something I can set > to get StorageType passed along? The image components will always be scaled up/down to the size of Quantum because GraphicsMagick's image model is exceedingly simple. The way to influence the default depth when writing is image->depth (e.g. image->depth=8). The StorageType argument does imply a particular size, which may or may not fit directly into Quantum. The maximum depth value supported by Quantum may be obtained from the QuantumDepth macro, which is fixed for any given GraphicsMagick build. If QuantumDepth is 16, then ShortPixel will fit exactly, and CharPixel will be scaled up (but could be claimed to have a 'depth' of 8). So it may make sense to set the default depth to the maximum bits given QuantumDepth and the size denoted by StorageType. I would like to be able to say that the solution is just to add image->depth = constitute_image->depth; but I see that ConstituteImage() has a bug in that it is not automatically setting the image depth parameter based on the size denoted by StorageType. I can fix this but it would not help you for a very long time. Sorry about that! Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt