-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDF converted from an icc-profiled raster images should use /ColorSpace /ICCBased
#417
Comments
/ColorSpace /ICCBased
/ColorSpace /ICCBased
Thanks for the detailed information that you provided. We will take a look at this at later time but this will help us a lot to figure out how to solve it. I will mark this issues as something that someone else could pick up also. |
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow. |
That's great news! Thanks. I looked at the diff and saw, that PDF version 1.7 isn't being chosen, when
Also, I saw, that in the ChangeLog file you reference this github issue. I was planning on removing the test file (mentioned in the test case) from my Dropbox. Is it fine for me to do that, or would you like me to upload it somewhere else? Thanks. |
Feel free to remove the test case image. IMv7 Beta produces a PDF version of 1.7 when it uses an ICCBased object. |
Okay, that's brilliant. Thank you for such a quick turnaround. I'll check the IMv7 Beta tomorrow. |
Just pushed a fix for the slash issue. Should be available in the beta tomorrow or you can download the |
Thank you very much @dlemstra, will do. Other than that, everything looks good to me 👍 |
It works fantastic now. Thanks again @dlemstra . One thing though. If you are able to stream the icc profile as a binary into the output pdf, instead of hex-encoding it, it would produce a smaller pdf. In this case you just need to drop the Thanks again. Can I close this ticket now or do you have a different process for closing tickets? |
We changed it to ASCII85Decode and saved about 800 characters. |
Can you give it another try @d-ph? If you are happy with the results you are free to close this issue yourself. Thanks for bringing this to our attention in this way and helping us add this feature. |
Everything still works and the output pdfs are now smaller. Thanks for such a rapid idea-to-release time. Pleasure's all mine. Cheers. |
2017-04-24 7.0.5-5 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 7.0.5-5, GIT revision 19908:bc92979:20170424. 2017-03-26 7.0.5-5 Cristy <quetzlzacatenango@image...> * Minimize buffer copies to improve OpenCL performance. * Morphology thinning is no longer a no-op (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31650). * Patch two PCD writer problems, corrupt output and dark pixels (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=3164). * Support ICC based PDF's (reference ImageMagick/ImageMagick#417). * Fix improper EPS clip path rendering (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31722).
I don't see the fix regarding the ICC profile backported to 6.9.8-4 yet? Did that get overlooked or will that be on -5? https://github.com/ImageMagick/ImageMagick/blob/6.9.8-4/coders/pdf.c#L2188 |
Right, the fix for this got in - but I'm curious if the additional fix in this comment got covered? #417 (comment) When I look at ln 2188 in the 6.x branch I'm seeing no slashes and running into a problem that looks identical to the bug he reported. Or am I chasing a red herring and the slashes described there weren't the issue? |
And I just found that commit and was going to update with that here so you didn't have to go hunting. Cool - then whatever is slagging my PDF is probably coming from something else. Thanks! :) |
Ok, I'll take a look. |
Or maybe it is. If you could create a ticket with steps to reproduce your problem (including the test file), I might be able to tell more. |
@fmw42 The malformed The To all people getting here from google: ImageMagick versions Sorry for the inconvenience caused and thanks for your reports. |
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow. |
Pkgsrc changes: Adapt to new version, PLIST (2 new files). Upstream changes: 2017-05-12 6.9.8-5 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-5, GIT revision 11575:186b15d:20170512. 2017-05-10 6.9.8-5 John Cupitt <jcupitt@gmail.com> * Revise DICOM window and rescale handling (reference ImageMagick/ImageMagick#484) 2017-05-08 6.9.8-5 Cristy <quetzlzacatenango@image...> * Fix transient PDF bug (reference ImageMagick/ImageMagick#463). * Check for EOF conditions for RLE image format. * Reset histogram page geometry (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31920). 2017-04-24 6.9.8-4 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-4, GIT revision 11521:d7433aa:20170424. 2017-03-26 6.9.8-4 Cristy <quetzlzacatenango@image...> * Minimize buffer copies to improve OpenCL performance. * Patch a PCD writer problem, dark pixels (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=3164). * Support ICC based PDF's (reference ImageMagick/ImageMagick#417). 2017-03-24 6.9.8-3 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-3, GIT revision 11444:3f523e5:20170324. 2017-03-20 6.9.8-3 Cristy <quetzlzacatenango@image...> * MagickWand-config, use --cflags, not --clags (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31602). * Respect -loop option for animate -window (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31619). 2017-03-18 6.9.8-2 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-2, GIT revision 11436:a912791:20170318. 2017-03-14 6.9.8-2 Cristy <quetzlzacatenango@image...> * Support namespaces for the security policy. 2017-03-11 6.9.8-1 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-1. 2017-03-03 6.9.8-0 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.8-0, GIT revision 11408:da91a7c:20170311. 2017-03-06 6.9.8-0 Cristy <quetzlzacatenango@image...> * Respect throttle policy (reference ImageMagick/ImageMagick#393). * Support the -authenticate option for PDF (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31530). 2017-03-03 6.9.7-10 Cristy <quetzlzacatenango@image...> * Release ImageMagick version 6.9.7-10, GIT revision 11396:44b1bc6:20170303. 2017-02-21 6.9.7-10 Cristy <quetzlzacatenango@image...> * Fix Spurious memory allocation message (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31438). * Identical images should return inf for PSNR (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31487).
Hello,
Sorry for the wall of text. The problem is simple. I think the solution isn't that difficult either. The explanation is what needs elaboration.
tl;dr:
In order for PDFs produced by ImageMagick from icc-profiled raster images to be correctly displayed in Adobe Reader, I need ImageMagick to instead of doing the following:
to be doing the following:
Further ado:
Would it be possible to make PDFs, converted from icc-profiled raster images, be created with the image XObject that uses
/ColorSpace [ /ICCBased (data) ]
, please?Currently ImageMagick includes the icc profile in the XObject's binary data. This icc profile is not interpreted by Adobe Reader (and many other apps), making the image be rendered with incorrect colours. I propose, that ImageMagick continue doing what it's doing (there is a very good reason for it), but additionally ImageMagick should also use the
/ColorSpace /ICCBased
, so the whole world beside ImageMagick can also benefit from icc-profiled images.Test case:
You'll also need:
pdftk-server
(link: https://www.pdflabs.com/tools/pdftk-server) to fix the edited PDF. On Windows you can usechoco install -y pdftk-server
.magick jpeg_ProphotoRGB_8bits_embedded_profile.jpg 1.pdf
1.pdf
andjpeg_sRGB_8bits.jpg
--> Result: colours are different (especially the red).magick jpeg_ProphotoRGB_8bits_embedded_profile.jpg 1.icc
--> icc profile is extracted1.icc
. One way of doing it is to run this:php -r "echo bin2hex(file_get_contents('1.icc'));"
cp 1.pdf 1dirty.pdf
vim 1dirty.pdf
. Find this:Replace it with this
pdftk 1dirty.pdf output 1fixed.pdf
jpeg_sRGB_8bits.jpg
and injpeg_ProphotoRGB_8bits_embedded_profile.jpg
I included
0.pdf
and0fixed.pdf
in the file available in step 1, as a reference.Implementation details:
File:
coders/pdf.c
/ICCBased
colour space (ref page 252):According to the PDF Reference link, I say it's best to use PDF version 1.7 for the
/ColorSpace /ICCBased
. See page 253 (starting at the bottom).If ImageMagick is able to extract the icc profile from the input raster file (i.e. step 4 from the test case succeeds), then the output pdf should be produced in version 1.7.
/ICCBased
colour space. Alternatively, the thumbnail might just be in sRGB, but ImageMagick would need to convert the color space from the original one to sRGB prior Thumbnail inclusion.Final words.
This change would make one more thing to JustWorkTM in ImageMagick. There are a couple of links in the google showing, that some people stumble upon this problem. I am one of them.
I'd prefer someone knowledgable in C to create the PR instead of me. I'm a php/javascript developer. I don't know how to compile stuff.
Many thanks,
@d-ph
The text was updated successfully, but these errors were encountered: