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.
Setting TrueColor on Grayscale JPEG
Re: Setting TrueColor on Grayscale JPEG
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.
$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.