php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70477 Converting image from Grayscale to RGB
Submitted: 2015-09-11 21:00 UTC Modified: 2015-09-19 12:35 UTC
From: cliff at obro dot nl Assigned:
Status: Not a bug Package: imagick (PECL)
PHP Version: 5.6.13 OS: CentOS 6.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cliff at obro dot nl
New email:
PHP Version: OS:

 

 [2015-09-11 21:00 UTC] cliff at obro dot nl
Description:
------------
I'm tying to convert an image from Grayscale setting to RGB but it's not working using Imagick


When i try the convert cli with the following it works
convert image.jpg -set colorspace RGB -type truecolor image_rgb.jpg

I'm not sure if i'm doing anything wrong here 

Versions 
Version: ImageMagick 6.9.2-0 Q16 x86_64 2015-09-04 http://www.imagemagick.org
imagick 3.3.0RC2 beta

Test script:
---------------
$imagick = new \Imagick($sourcePath);
$imagick->setImageType(\Imagick::IMGTYPE_TRUECOLOR);
$imagick->setColorspace(\Imagick::COLORSPACE_SRGB);
$imagick->setImageColorspace(\Imagick::COLORSPACE_SRGB);
$imagick->transformImageColorspace(\Imagick::COLORSPACE_SRGB);
$imagick->setImageProperty('colorspace', 'RGB');
$imagick->writeImage($imagePath);

Expected result:
----------------
I expect an image to be simalar to this using the identify command from imagick 
JPEG 1280x720 1280x720+0+0 8-bit sRGB 1.418MB 0.000u 0:00.000


Actual result:
--------------
After this command i'm using identify to get details about the generated image and this is the result. 
JPEG 1280x720 1280x720+0+0 8-bit Gray 256c 44.6KB 0.000u 0:00.000

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-19 12:35 UTC] danack@php.net
-Status: Open +Status: Not a bug
 [2015-09-19 12:35 UTC] danack@php.net
Apparently it is an internal optimisation ImageMagick does if the image only contains gray colors to output it as grayscale. Try adding an explicit call to setType:

$imagick->setType(\Imagick::IMGTYPE_TRUECOLOR);

Which forces the output type to be what you want.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 14:01:29 2024 UTC