Page 1 of 1

Same Code; Different Linux Distros; Different Results

Posted: 2017-08-18T10:12:48-07:00
by darkwingduke
The images produced on Ubuntu look great, but the ones on CentOS look washed out. (See Attachment)
I'm not sure if this is a version issue or if I'm missing something in my code.

Here are my specs:
Ubuntu 14.04
ImageMagick 6.7.7-10
Ghostscript 9.10
Imagick 3.4.3RC2
PHP 5.6.18
**************
CentOS 6.9
ImageMagick 6.7.2-7
Ghostscript 8.7
Imagick 3.4.3
PHP 5.6.23

Here's my code:
define("UPLOAD_DIR", ***DB_DIRECTORY***);

//CREATE IMAGICK OBJECT AND GET BACKGROUND CMYK PDF IMAGE FROM LOCAL DIRECTORY
$backgroundImage = new Imagick();
$backgroundImage->setResolution(350,350);
$backgroundImage->readImage(***CMYK_PDF_BACKGROUND***);
$backgroundImage->setImageFormat("pdf");

//GET FOREGROUND SRGB CANVAS ELEMENT FROM BROWSER
$rawCanvasData = $_POST["srgb_canvas_image_from_browser"];
$raw_data_parts = explode(',', $rawCanvasData);
$rawCanvasImage = $raw_data_parts[1];
$canvasImage = base64_decode($rawCanvasImage);

// CREATE IMAGICK OBJECT AND CONVERT CANVAS IMAGE INTO IMAGICK
$foregroundImage = new Imagick();
$foregroundImage->setResolution(350,350);
$foregroundImage->readImageBlob($canvasImage);
$foregroundImage->setImageFormat("pdf");
$foregroundImage->transformImageColorspace(imagick::COLORSPACE_CMYK);

//APPLY FOREGROUND TO BACKGROUND
$backgroundImage->compositeImage($foregroundImage, Imagick::COMPOSITE_DEFAULT, (((($backgroundImage->getImageWidth()) - ($foregroundImage->getImageWidth())))/2), (((($backgroundImage->getImageHeight()) - ($foregroundImage->getImageHeight())))/2));

// SEND FINAL IMAGE TO DIRECTORY
header("Content-Type: image/pdf"); //I don't think the header is actually necessary
$magickFile = UPLOAD_DIR . DIRECTORY_SEPARATOR . "imagick_image" . ".pdf";
$success = file_put_contents($magickFile, $backgroundImage);

Any assistance with this issue would be greatly appreciated. Thanks.

Re: Same Code; Different Linux Distros; Different Results

Posted: 2017-08-18T10:24:12-07:00
by fmw42
Imagemagick uses Ghostscript to read PDF files. Check to see that both systems have the same version of Ghostscript. My current version is

gs --version
9.21

I would also suggest that you convert CMYK to sRGB before doing any processing and then if you want the result to be CMYK, do that at the end. Best results if you use profiles for the conversion.

IM 6.7.7.10 is very old. But there may be patches to more current versions. Check the dates associated with the versions on Linux systems. Be sure they are patched to the same date. Also be sure that they are patched to the latest patch, since some recent patches have been buggy, but fixes have been issued, that may not have been implemented in your versions.

Re: Same Code; Different Linux Distros; Different Results

Posted: 2017-08-18T13:17:17-07:00
by snibgo
Are these images grayscale? Do you have the same problem with colour images?

Around the time of your versions, IM was confused about grayscale sRGB. I suggest you upgrade to current versions.