I can try. Do you have a PDF available for testing? It’s hard to pinpoint the reason before I’m able to reproduce the problem. It could be related to the file size, is this a large PDF? The code I use to generate a thumbnail is as follows:
$imagick = new Imagick($filename);
$imagick->setIteratorIndex(0);
$imagick->setImageFormat('jpg');
return $imagick->getImageBlob();
Other than that, it’s mostly just code to update metadata for WordPress, not directly related to image generation.
Image generation can be overridden by the pdf_thumbnails_generate_image_blob filter as described under developer API for this plugin. If you feel confident coding PHP, I suggest using that filter and see if you can figure out how Imagick handles the uploaded files that are failing, maybe you can get some useful debugging information from there.
-
This reply was modified 9 years, 4 months ago by
stianlik.
Dear stianlik,
In my post, I have already given a sample of pdf that generates the problem (third link).
As you can see it is a small file (less than 1 MB).
Cordially,
Mohamed Belhassen
Than you. I can confirm that I’m getting the same error on my side. Will look into the issue.
The problem is that the PDF does not have a background, and the transparency is rendered as black. I did not find any good solutions to handle this type of PDF, other than saving the PDF with a white background before uploading. You can observe the same problem by using ImageMagick in the command line:
`
convert 275_tp1_integration_web_statique_html_css.pdf[0] foo.jpg
`
Currently, it does not seem to be a good solution that handles these PDFs using imagick. I was able to avoid the issue by opening the file in a PDF-editor and setting page background to white. Marking the issue as resolved.
Dear Stialik,
Coould you please mention the name of the PDF editor that let us modify the backgroud?
I am using Foxit Reader but no similar option is available.
Cordially,
M.B
For the first test, I opened the file using LibreOffice, set background to white and saved the file. However, LibreOffice did not handle the PDF too well, some of the text got scrambled. It looks like the PDF originally was generated using Word, so it may be possible to fix the background using Word.
In my second test, I simply opened the PDF using Evince, and chose print to PDF, and uploaded the “printed” file. Evince gave good results. I’m testing on Linux, but I assume there is similar functionality in Windows or OSX.