Same Code; Different Linux Distros; Different Results

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
darkwingduke
Posts: 8
Joined: 2017-01-11T14:43:03-07:00
Authentication code: 1151

Same Code; Different Linux Distros; Different Results

Post 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.
Attachments
Ubuntu-Left_Centos-Right.png
Ubuntu-Left_Centos-Right.png (49.4 KiB) Viewed 13914 times
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Same Code; Different Linux Distros; Different Results

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Same Code; Different Linux Distros; Different Results

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply