Re: Preventing -extent from converting to RGB
Bob Friesenhahn <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 28 Aug 2016, [email protected] wrote: >>> >>> Did you try making the background a grayscale colour? >> >> That was my first thought too, but the doc only talks about RGB colours; >> there was no obvious way to specify a single channel "colour." (Of >> course there may be a way I missed.) > > Try "-background white", "-background black", "-background '#a0a0a0'", > etc. As long as all three components of the background color are > equal, it won't force GM to write an RGB image. > > BTW I'm assuming you are writing a PNG, and working with the current > version of GM. The ExtentImage() function is very simple. First it clones the input image to a new image, then uses SetImage() to set the new image to the specified background color using the specified opacity. Secondly, it uses CompositeImage() to composite an image at the specified offsets using the specified composition operator. The use of CompositeImage() will promote the image to DirectClass type and it is possible that SetImage() produces DirectClass type as well. With some work is possible for the code to intuit when PseudoClass can be used, and if the resulting image is grayscale. Some of this intuiting may already be done. Otherwise a DirectClass image will be produced. Using '-type Optimize' may help by inspecting all the pixels to see if they are grayscale, but this won't cause the image to be converted to PseudoClass (colormapped). At one time, the PNG writer was making special use of '-type Optimize' but I think that support was removed. Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ ------------------------------------------------------------------------------