PDF image covers are inverted in thumbnails

Hi all,

One of my colleagues batch uploaded a number of PDFs of our university magazine, but the thumbnails show the negative of the cover. However when we go to the direct file, the PDF displays normally in each record. Is this a case with having to manipulate something within the PDF files themselves or is my thumbnail plugin acting up? I’ve never come across this issue so far, so I’m wondering if anyone else has and if they have any easy fixes.

Thank you all for your help!

Sincerely,
Suzanna

I met the same issue here today. After some research, I think it’s due to how ImageMagick handles the pdf file with the color model in CMYK. As long as the pdf file’s color mode is RGB, the generated thumbnail will be fine. So the solution can be either convert the original pdf’s color mode to RGB or switch the setting of “fileDerivatives.strategy” in “application/config/config.ini” to a different value. BTW, The “Omeka_File_Derivative_strategy_GD” can not generate thumbnails for pdf files properly.

My recollection is that the last time this came up, I wasn’t able to reproduce the problem. So it’s at least partially just an issue of versions of ImageMagick and/or Ghostscript fixing this problem.

I’m happy to try again if you have an example problematic PDF.

We started having this issue after upgrading to 2.7.1 late last year. Any PDFs uploaded since then (all greyscale) have the inverted thumbnails. Here’s an example: https://digitalarchives.sjc.edu/items/show/7515.

This is another one where the ImageMagick setup I have just does it correctly, hmm.

2.7.1 didn’t really change anything about this so it may be some other change on your server or otherwise (or with the PDFs themselves) that’s caused the difference for you.

Not sure whether it helps you, but I’ve tried to upload the same PDF and I got your same result (inverted thumbnail). Since all my other PDFs are showing correctly, I would vouch with some kind of issue with the PDF itself (since John did not experience the same issue, it could be that something in the PDF is triggering something else in ImageMagick specific version…).

I think the common factor is that the “problem” PDFs are using CMYK color, but what I can’t figure is what’s the difference in server setups that causes some people to get this inversion and not others.

It’s probably either ImageMagick or Ghostscript… I would probably guess ImageMagick first but Ghostscript is also possible.

This topic was automatically closed after 250 days. New replies are no longer allowed.

An update: having finally encountered a server configuration where this problem seems to occur (still not quite sure what in particular makes an environment prone to this problem, but regardless), I’ve made some possible headway in resolving the issue.

This commit replaces part of the ImageMagick command we use to make thumbnails (specifically the argument -flatten) with a more modern way to accomplish what we want (-alpha remove). In my testing, that change resolves the “inverted colors” issue with CMYK images and PDFs.

If any of the people here who were/are experiencing this issue are interested in trying this out and comfortable applying a patch or making a change, it would be nice to know if this resolves the issue for you as well. Note: to use this, you need ImageMagick newer than 6.7.5-1 (this is quite old so shouldn’t be an issue), and you need to set your ImageMagick version in the Omeka application/config/config.ini file (fileDerivatives.strategyOptions.version).

Hi John,

Thank you for troubleshooting this issue–my network guy seems to have done what you suggested and the thumbnail images are still inverted. Do you have any possible workarounds or suggestions for what we should do to fix this?

Thank you for your help,
Suzanna

I can’t guarantee that this would fix the problem for everyone, it just did for the particular setups that I had access to.

Just to make sure we’re on the same page, the fix here would require both applying the patch I linked and setting the proper version in the application/config/config.ini file. As far as you know, both of these were done on your server? I’d want to be sure that the “fix” is in place before concluding that it doesn’t work on your server.

My network guy said the following, John:

I added the line in the config.ini. Not sure how much of the ImageMagick version I need there. Here is how I added the entry in the config.ini:

fileDerivatives.strategyOptions.version = “ImageMagick 6.9.10-68”

If I run the convert -version command I see the following:

Version: ImageMagick 6.9.10-68 Q16 x86_64 2021-10-14

I don’t know if I have to add the entire thing or not. Please retest and let me know

The line should just be

fileDerivatives.strategyOptions.version = "6.9.10-68"

But of course it only has an effect on this problem if the linked patch is also applied.

Hi John,

Thank you for your patience with us as we troubleshoot this issue. My network guy just got back to me and said “I applied the patch and updated the ini file and it’s still not working”

Is there anything else we can do?

Thank you for your help,
Suzanna

Okay, so just to cover our bases: On the config file, the line should look exactly like the one I posted (in particular, there should be no semicolon at the start of the line).

If that’s all set up and the patch is applied, then you should be seeing the “fix.” One final note is that the effect will only be seen with newly uploaded files: it won’t change thumbnails that have already been made. So to test it you have to reupload one of your PDFs.

If you’ve got the patch applied, the proper config file line, and you upload a new file and it still has this problem, then we’d have to conclude this fix doesn’t work for you.

John,

Thank you for clearing that up! I didn’t realize I’d have to reupload the pdfs so once I did that resolved the issue.

Thank you for being such a lifeline during this troubleshooting issue, you ROCK.

Cheers,
Suzanna

Okay, glad to hear it’s working for you.

Thanks for sharing that it did end up working, it’s good to know that the fix is more broadly useful for other people who have had this problem.

You could look into using the Derivative Images plugin if you want to re-make a large number of old thumbnails without having to reupload all the original files.