Issue
I have a task where I need to take PDFs that are mock ups of printing products, and check their resolution, size and colour-space. I need to use Imagick with PHP to complete this task.
The printing shop that will print these PDFs only have CMYK printers and so, the uploaded PDF need to have CMYK colours. But I am not clear on how colour-spaces(CMYK/RGB) work in PDF, or in jpeg/png images. So, I have a few questions that will hopefully help me understand the thing better and complete the task:
From what I understand, we can draw objects or add images to the pdf that can have their colours defined as RGB or CMYK, but how does this affect the colour-space of the entire PDF?
Is it possible to check the colour-space of a PDF in php, without converting it jpeg/png?
If I have images in a PDF defined in either CMYK or RGB colour-space and convert the PDF to jpeg/png with Imagick, does the colour-space remain the same in the converted image unless specifically mentioned by
Imagick::transformImageColorspace()
?A short background information on how colour-spaces work, how they are defined and detected and how they are affected when the file is converted from one mime-type to another.
P.S.: I am converting the PDFs to jpeg/png and checking the colour of the converted file as below, but it always gives false
, no matter what pdf I use.
$img = new imagick(self::$_imgArray[0]);
if($img->getimagecolorspace() == imagick::COLORSPACE_CMYK)
echo "Image is in CMYK";
Solution
I have a task where I need to take PDFs that are mock ups of printing products, and check their resolution, size and colour-space.
A PDF page does not have a resolution (though images on the page do). It does have a "physical" dimension, default being Letter size. PDF units are by default 1/72 inch. If a PDF page contains pure vector data, then it look great at any resolution.
See below for more detail, but a single PDF page/document can contain one or more of Gray, RGB, CMYK, LAB, and more, color spaces.
- but how does this affect the colour-space of the entire PDF?
It doesn't, the PDF itself does not have an overall color space. Typically a PDF processor would convert all graphics to a target color space, e.g. Chrome would at some point have everything in RGB since it is drawing to a screen.
- Is it possible to check the colour-space of a PDF in php, without converting it jpeg/png?
Sure, though a single PDF could contain greyscale, rgb, cmyk, lab, separation colors, etc. Again, there is no one color space in a PDF file.
- If I have images in a PDF defined in either CMYK or RGB colour-space and convert the PDF to jpeg/png with Imagick, does the colour-space remain the same in the converted image unless specifically mentioned by Imagick::transformImageColorspace()?
It would depend on the software doing the conversion. Since PNG does not support CMYK, then at the very least any CMYK would be converted. Exactly what happens depends on the software, the settings, and the target output format and what is supports.
- A short background information on how colour-spaces work, how they are defined and detected and how they are affected when the file is converted from one mime-type to another.
See section 8.6 here: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf Here is another good link https://www.color-management-guide.com/color-spaces.html
Answered By - Ryan Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.