A customer has been using this module for some time to turn their pdf's into jpg's. Since a few days they have been experiencing black backgrounds on the images that are now being generated.
I investigated this and it turns out to be an imagemagick bug (https://www.imagemagick.org/discourse-server/viewtopic.php?t=16371).
It only happens with pdf's that are created from an image with a certain colour scheme (CMYK color document), as the bug report mentions.
Also, it seems to only happen with certain versions of Imagemagick. Locally I don't experience the bug, and I run ImageMagick 6.7.8-9 2016-06-16 Q16. But on the server of the customer the bug is present, and they run ImageMagick 6.8.9-9 Q16 x86_64 2017-05-26.
Luckily, there is a workaround for this bug: add an argument to the command to force the background to be white.
I tried it, and it actually works! (see patch I'll commit in the next comment).
I thought it'd be neat to create a bug report of this anyways, so I can share this with you guys (the community).
Since I've never done this before, and I just learned how to do this (kind of) during DrupalCon Vienna, I ask you for your patience with me, as I'll probably make ample mistakes in the process.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | pdf_to_image_black_background-2913750-2.patch | 647 bytes | colorfulcoder |
Comments
Comment #2
colorfulcoder commentedSince I don't have a possibility to work with the newest version of the module (our customer doesn't want an update at this point) I'm going to create a patch for version 7.x-3.1 only.
I have already checked if the bug is still present in the newest version (7.x-3.3), which is the case.
But the patch won't run on the newest version due to refactoring of the code (whatever I patch has moved to another function).
Feel free to port the patch to the newest version! It would actually be even better if we could make a hook with which other modules could add arguments to the command. So new patches might want to focus on that. I posted this patch this way anyways, because something is better then nothing.
Thanks to dmsmidt and Nitebreed for helping me with this issue and creating my very first patch!
Comment #3
colorfulcoder commentedMy collegue came with a very good observation. In the content type where we have the pdf field that has to be converted to an image, you can actually edit the settings for the field, and one of the settings is "Extra conversion arguments". Here you can fill in any arguments you might want to use, like say "-alpha remove".
This does not fix the bug in version 7.x-3.1 (because for some reason that version does not take these arguments into account) but it does fix it for 7.x-3.4.
What we did therefore, is update the module and add that command to the field in the relevant content type.
The patch is solely for people that need to use version 7.x-3.1.
Comment #4
daggar commentedIn my case, the extra conversion arguments "-alpha remove" wasn't enough. I needed to set the background color as well, so I used:
-background white -alpha removeComment #5
djmolny commentedTo be clear, those extra conversion arguments are applied to the field containing the PDF file -- not the file containing the generated thumbnail.
Comment #6
hitchshockWe stopped supporting the D7 version, so the ticket will be closed, but thanks to everyone who was working on the ticket!