Same Code; Different Linux Distros; Different Results
Posted: 2017-08-18T10:12:48-07:00
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.
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.