php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72481 CMYK color space is invalid for ImagickDraw
Submitted: 2016-06-23 23:59 UTC Modified: 2016-07-10 04:22 UTC
Votes:4
Avg. Score:2.8 ± 1.1
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: me at liudonghua dot net Assigned: danack (profile)
Status: No Feedback Package: imagick (PECL)
PHP Version: 5.6.23 OS: CentOS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-06-23 23:59 UTC] me at liudonghua dot net
Description:
------------
The sample code is below. $fg and $lg used in ImagickDraw are unexcepted in image.
php version: 5.6.21, imagick version: 3.4.2.

Test script:
---------------
$fg = "cmyk(0,0,0,100)";
$bg = "cmyk(0,1,0,0)";
$lg = "cmyk(1,0,0,0)";
$image_size = 200;

$fg_pixel = new ImagickPixel($fg);
$bg_pixel = new ImagickPixel($bg);
$lg_pixel = new ImagickPixel($lg);

$image = new Imagick();
$image->newImage($image_size, $image_size, $bg_pixel);
$image->setImageColorspace(Imagick::COLORSPACE_CMYK);
$image->setImageFormat('jpeg');

$profiles = $image->getImageProfiles('*', false);
$has_icc_profile = (array_search('icc', $profiles) !== false);
if ($has_icc_profile === false) {
    echo "load icc file.\n";
    $icc_cmyk = file_get_contents('JapanColor2001Coated.icc');
    $image->profileImage('icc', $icc_cmyk);
    unset($icc_cmyk);
}

$draw = new ImagickDraw();
$draw->setStrokeColor($lg_pixel);
$draw->setFillColor($fg_pixel);
$draw->setStrokeWidth(6);

$draw->rectangle(30,30,80,80);
$image->drawImage($draw);
$image->writeImage("cmyk.jpg");

$fg_pixel->destroy();
$bg_pixel->destroy();
$draw->destroy();
$image->destroy();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-26 22:50 UTC] danack@php.net
-Assigned To: +Assigned To: danack
 [2016-06-26 22:58 UTC] danack@php.net
Please can you say how you are determining the image is wrong?

CMYK is a substractive colorspace. You are starting with pure black....and then taking color away from it, which leads to it still being black....which sounds about right?


Transforming the image to RGB before writing with:
$image->transformimagecolorspace(Imagick::COLORSPACE_SRGB);

gives an 'expected' result, probably.
 [2016-06-27 19:47 UTC] danack@php.net
-Status: Assigned +Status: Feedback
 [2016-06-27 19:47 UTC] danack@php.net
I'm setting this to feedback, as I'm not sure what I'm meant to be looking for to fix.
 [2016-06-28 02:19 UTC] me at liudonghua dot net
Do I taking color away from the image? Which line code?

You can test the code, it'll create a CMYK image named 'cmyk.jpg', and get the colors CMYK values by photoshop. The image I posted on this page: http://liudonghua.net/use-imagemagick-to-create-cmyk-image-in-php/
 [2016-06-30 20:48 UTC] danack@php.net
This is the image I get when I use the code below: http://phpimagick.com/images/cmyk.jpg

When viewed in preview on my Mac it looks black. When viewed through Chrome it appears the correct way round.

I'm sorry but I don't understand what you're reporting as the issue, so can't investigate it.

cheers
Dan



<?php

$fg = "cmyk(0,0,0,100)";
$bg = "cmyk(0,1,0,0)";
$lg = "cmyk(1,0,0,0)";
$image_size = 200;

$fg_pixel = new ImagickPixel($fg);
$bg_pixel = new ImagickPixel($bg);
$lg_pixel = new ImagickPixel($lg);

$image = new Imagick();
$image->newImage($image_size, $image_size, $bg_pixel);
$image->setImageColorspace(Imagick::COLORSPACE_CMYK);
$image->setImageFormat('jpeg');

$draw = new ImagickDraw();
$draw->setStrokeColor($lg_pixel);
$draw->setFillColor($fg_pixel);
$draw->setStrokeWidth(6);

$draw->rectangle(30,30,80,80);
$image->drawImage($draw);
$image->writeImage("cmyk.jpg");
 [2016-07-10 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC