Re: MagickSetImageType and gm convert: inconsistent behaviour
Graham Leggett <[email protected]> Tue, 28 Sep 2010 12:32:49 +0200
| Newsgroups | gmane.comp.video.graphicsmagick.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 23 Sep 2010, at 5:29 AM, Bob Friesenhahn wrote:
>> Is a grayscale image supposed to be in the RGB colourspace, and am I
>> misunderstanding this?
>
> Grayscale is a form of RGB colorspace (at least as far as
> GraphicsMagick is currently concerned).
I suspected this was the case.
> It is easy to see why the behavior is confusing.
> MagickSetImageType() only operates on the image (Image struct). The
> command line tool is also setting 'type' in ImageInfo, which is used
> when a file is saved. MagickSetImageType() is not doing that.
> Perpaps this should be added to MagickSetImageType():
>
> wand->image_info->type=image_type;
>
> So that the function looks like:
>
> WandExport unsigned int MagickSetImageType(MagickWand *wand,
> const ImageType image_type)
> {
> assert(wand != (MagickWand *) NULL);
> assert(wand->signature == MagickSignature);
> if (wand->images == (Image *) NULL)
> ThrowWandException(WandError,WandContainsNoImages,wand->id);
> wand->image_info->type=image_type;
> return(SetImageType(wand->image,image_type));
> }
>
> The drawback of this is that the Image type operates immediately on
> the pixels (if required) so that it is an image processing operation
> whereas the type stored in ImageInfo is only used when saving the
> image. These are two somewhat different functions which may or may
> not always end up with the same result. For example, there could be
> a request to convert the image to a gray image, and then something
> with the color red is composited on top of it. The image is then a
> RGB image but would still be saved as gray (if possible) due to also
> setting ImageInfo to the desired type. The user would need to
> remember to set the image back to an RGB color type.
Would it make sense to introduce a new API function, say
MagickSetSavedImageType() and MagickGetSavedImageType(), which
operates on wand->image_info->type directly?
In this way, the gm convert function can use
MagickSetSavedImageType(), and work as it does now, and the
MagickSetImageType() would remain unchanged.
In this way, the API remains unchanged for existing code.
Would this be workable?
Regards,
Graham
--
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev