Setting TrueColor on Grayscale JPEG

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
Madnesz
Posts: 2
Joined: 2012-06-17T03:44:05-07:00
Authentication code: 13

Setting TrueColor on Grayscale JPEG

Post by Madnesz »

When loading a greyscale image into memory, it is automatically changed into image type to 2 (GrayScale). As I cannot use greyscale JPG's in further processing, I need to keep its original image type 6 (TrueColor). However, I cannot find any working method to do so. Here's what I get when loading a greyscale JPG which originally has a 24 bit depth, but after using ImageMagick is changed to 8 bit depth.

$img = new Imagick();
$img->readImage($source);
$img->setImageType(6);
echo $img->getImageType();

Still outputs 2. Is this a bug or a design choice? If it's a design choice, is there any workaround?

Please note that saving the image to file, also produces an 8 bit depth photo, so it's not just the getImageType() function.
Madnesz
Posts: 2
Joined: 2012-06-17T03:44:05-07:00
Authentication code: 13

Re: Setting TrueColor on Grayscale JPEG

Post by Madnesz »

Fixed it! The key was to use:

$img = new Imagick();
$img->setType(6); (instead of $img->setImageType() after loading the image)
$img->readImage($source);

It now outputs an image of type 6.
Post Reply