MagickCompositeImage and colorspaces

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

MagickCompositeImage and colorspaces

Post by Danack »

When using MagickCompositeImage to composite an image in CMYK colorspace into an image in RGB colorspace, the image being composited does not appear to be converted to the correct colorspace before being composited.

The example code was reported in PHP, I can convert this to C if required.

Code: Select all

$img=new Imagick();
$img->newImage(700,700,new ImagickPixel('#f0f'));  //Calls MagickNewImage(magickwand, 700, 700, color_wand) 
$pic=new Imagick('im.jpg'); //This image is in CMYK
$pic->thumbnailImage(500,500);
$img->compositeImage($pic,imagick::COMPOSITE_DEFAULT,100,100);
$img->writeImage("worldMapOutput_cmyk.jpg");

This produces the image:

Image

Where the map has been composited as CMYK, but the background image is in RGB space. This was tested with ImageMagick 6.9.0-7

This can worked around by explicitly converting the image that is going to be composited to the RGB colorspace. I would have expected this to happen automatically.

Source image if required is here:
https://cloud.githubusercontent.com/ass ... db4404.jpg
Last edited by Danack on 2015-04-04T08:20:09-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickCompositeImage and colorspaces

Post by magick »

The ImageMagick design philosophy is do what the user wants-- not what we think the user wants. The command-line makes some exceptions, but for the various API's, we assume the developer knows what they are doing, and if they want to composite an RGB image over an CMYK image, that's ok.
Post Reply