PDF Thumbnail generation not working
-
Hello,
I can’t get MLA to generate thumbnails for my pdf. I have ImageMagik/GS installed. The generation works with Document Gallery for example.
Here is my test article combining MLA and Document Gallery.
https://rf-efh.org/generalites/test-gallerie/Here is my test process:
1/ Create test article
2/ In test article, insert media / add pdf file
3/ In the body of the article, add short code [mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_viewer=true mla_viewer_page=2 columns=1 orderby=date order=desc mla_debug=true]
4/ Save / PreviewYou can see that DG can generate the thumbnails but not MLA. I have activated the debug mode in shortcode and in wp-config => I have a debug tab… but empty.
I tried of course with DG disabled, it doesn’t change anything.
What is wrong with my setup?
-
Thanks for your question and for the test article link and test process details; very helpful.
I have been unable to access your
test-gallerie
page; it says “Maintenance en cours”. I will try again tomorrow.In the interim, can you tell me more about your symptoms?
- Do you get PDF icons or broken image links for your
[mla_gallery]
items? - Have you tried leaving out the
mla_viewer_page
parameter?
The
mla_debug=true
parameter should be displaying a lot of debug messages in the[mla_gallery]
output. It will not write anything to the error log file. Also, it will return information about composing the gallery output but not about the thumbnail generation process, which is done in a separate call back to the server. If I cannot solve your problem quickly I will investigate adding more debug information to a Development Version of the MLA plugin.Any additional information you can give will be helpful. Thank you for your patience.
Hello David,
Thank you for the quick answer. Please login with account testREEFH / test12 to bypass the maintenance notification (site under construction).
– Icons: I have the PDF icons (no broken image links)
– I tried without mla_viewer_page, it doesn’t seem to have any effects.mla_debug=true seems to display the queries but not the PHP calls indeed.
A few more info:
$ type gs gs is /usr/bin/gs
Also it seems there is a limitation on my server to 1 thread.For example:
$ convert Logo.png -resize 64x64 logo_resize.png
generates the following error:
libgomp: Thread creation failed: Resource temporarily unavailable
But
$ convert -limit thread 1 Logo.png -resize 64x64 logo_resize.png
is working.
Maybe a tweak is required when your code is calling gs, maybe DG has this tweak.
Your gallery system has the greatest potential for my use case. I hope we can find a solution ??
Thank you for your update with the additional information and the login credentials for the site. I was able to log in and see the page containing the test galleries.
For some reason which I will investigate MLA is not finding your installed Ghostscript and so is generating the PDF icons instead of the thumbnails. I will look into that.
In the interim, you can try turning the Ghostscript check off. Go to the Settings/Media Library Assistant MLA Gallery tab and scroll down to the “Enable explicit Ghostscript check” entry. Uncheck the box, scroll to the bottom of the page and click “Save Changes” to record the change.
Please let me know if that resolves the problem or if the symptoms change, for example, if you get broken image links instead of the PDF icons.
You might also try changing
mla_viewer=true
tomla_viewer=single
if you encounter a problem with the single-thread limit. I have not seen that issue before.Thank you for your help and for your patience.
Thank you for investigating this and for your quick follow up.
1/ Disable explicit Ghostscript check: I have now broken images instead of the pdf icon.
2/ mla_viewer=single: same result (with or without explicit Ghostscript check).
Current shortcode on the test page (if you want to see – Explicit gs check disabled):
[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_viewer=single mla_viewer_page=2 columns=1 orderby=date order=desc mla_debug=true]I also uploaded a new pdf to the test article to see if it would trigger a new generation… same.
Let me know if you need anything else.
Thank you for your testing and updates. The tests confirm my suspicion that for some reason MLA is not finding your Ghostscript program or not calling it successfully.
I am looking into the cause and also working on an MLA Development Version with more debug options and output. I will post an update here as soon as I have some progress to report. Thanks for your patience.
Further investigation reveals that your issue may be caused by Imagick, not Ghostscript. Document Gallery can process PDF documents without Imagick, but MLA requires Imagick for successful operation.
If you go to the Settings/Document Gallery General tab and scroll down to the “Thumbnail Generation” section, is the “Imagick” box checked and does it say “Use Imagick to handle lots of file types locally.”? If it says “Your server is not configured to run Imagick”, that is the cause of your problem.
You are correct. GS is OK but not Imagick! Let me go back to my provider.
The good news is somehow we can manage PDF thumbnail without Imagick.
Also I just tried to update MLA with your new version, it failed. It doesn’t show in the Extensions Plugin list anymore but I can’t reinstall it as the folder is still here. Maybe I should bring this to a new thread.
Thank you for your help.
Thank you for your update confirming that Imagick support is the cause of your problem. I will look at a better way to detect and report these support issues in a future MLA release.
I regret the trouble you’re having with updating to the latest version. This is a WordPress problem; MLA itself has nothing to do with the update process. I have had similar problems from time to time with different plugins, but simply installing from scratch usually fixes it. If not, can you delete the old directory using FTP or cPanel access to your site?
I am marking this topic resolved, but please update it if there is anything else I can do to help. Thanks for your persistence, your patience and your interest in the plugin.
OK I will try to “hard” delete the old directory. Thank you for the tip.
We can indeed close this topic. For Imagick support, I understand that hosting companies have to put specific rules to limit the potential impact on the server (for shared hosting solutions). Here is more information from my host:
https://www.inmotionhosting.com/support/website/software/using-imagemagick
If DG can do it, maybe you can find a way around it ??
Thank you anyway for looking into this.
Thanks for your update and for the link to your hosting company’s ImageMagick article. The emphasis in that article is on the more complex image-processing and batch-processing functions in ImageMagick; they can have a significant performance impact.
WordPress has been encouraging ImageMagick use for some time now:
In MLA, the main use of
mla_viewer
is to create thumbnail images for PDF documents. PDF handling in ImageMagick is not very good; it reads and converts the entire document even if just one page is needed. That’s why MLA (like DG) uses Ghostscript for PDF-to-image conversion. MLA uses ImageMagick for some other aspects of thumbnail generation, such as scaling and compression. These operations do not have performance issues in any of my tests. I plan to follow WordPress and stick with ImageMagick unless some specific issue comes up in the future.Thanks again for your engagement on this topic.
I have uploaded a new MLA Development Version dated 20150625 that includes a new “Thumbnail Generation” capability. The Media/Assistant “Thumbnail” Bulk Action lets you select one or more non-image items and generate new thumbnail image items you can use as the Featured Image for those items. That lets
mla_viewer
display the thumbnails without re-generating them each time the gallery is composed. You can find step-by-step instructions for using the Development Version in this earlier topic:I am very interested in feedback on this new feature. If you get a chance to try the Development Version please let me know how it works for you. Thanks for your interest in the plugin.
Hi David,
Sure, I’ll take a look. Just to be sure I understand: this version allows generating thumbnails for non-image items, I guess like video or pdf. Unfortunately my hosting company (InMotion) won’t allow ImageMagick as I am on a shared server (but I do have GS enabled). Won’t that be an issue for the generation of the thumbnails? Just want to make sure I am a relevant test case here ??
TheNemal
Thank you for your response and the additional comments.
The current MLA Development Version and the new thumbnail generator work for PDF, AI (Adobe Illustrator), EPS (Encapsulated PostScript) and PS (PostScript) files. These are the types supported by Ghostscript and ImageMagick. I have not explored the work required for Video thumbnails.
The current version also requires Imagick/ImageMagick support for the reasons given in my earlier post. When I read through the InMotion article you linked to I found this statement:
By default, ImageMagick is installed on InMotion Hosting servers. However, it can only be accessed through the command line, a cron job or PHP code on a web page.
…
ImageMagick has many modules that can be loaded, but for the purposes of InMotion’s hosting servers, the main commands available are Convert and Mogrify. These commands can be used through PHP using a native extension called Imagick. For more information, please see the Imagick class in the PHP documentation.
I understand that to mean that Imagick support is available to you. Have you had a different answer from the support team?
If you can’t get Imagick/ImageMagick support, I regret that you won’t be able to use the Development Version.
By the way, I did add a better way to detect and report the support conditions to this latest version; thanks for motivating that improvement.
Hello David,
I tested dev version 20150626 based on your instructions. I went to the assistant, selected a PDF and asked for Thumbnail generation.
I received the following error message. As you saw on my provider’s page, I think the ImageMagick setup is very restricted for shared hosting setup and it seems there is a specific way to call it in PHP.
ERROR: Item 508, thumbnail generation failed – Imagick not installed
Is your command with the following syntax? (not sure where to look in your code)
exec('/usr/bin/convert /home/USERNAME/public_html/larger-image.png -resize 64x64 /home/USERNAME/public_html/smaller_image.jpg');
Thank you for investigating this.
Sebastien
Thank you for your continued efforts to get this working – I really appreciate your persistence.
ImageMagick and Imagick are two separate components; Imagick is not part of ImageMagic. It took me a couple of tries with my web hosting company to get the information I needed to add Imagick support to my shared server. When I first asked my production hosting company about support I was told:
You can add a php.ini file to your account and add the following line to it
extension=imagick.so
If the modules are not available on your particular server we can see about adding them but will need to be evaluated by an administrator.After I created a php.ini file with the above line, it still didn’t work. I reported that and they fixed it. You can find some additional information in this earlier topic:
The actual Ghostscript call is in /includes/class-mla-image-processor.php, function
_ghostscript_convert()
. There you will find:$cmd = escapeshellarg( $ghostscript_path ) . ' -sDEVICE=%1$s -r%2$dx%2$d -dFirstPage=%3$d -dLastPage=%3$d -dFitPage -o %4$s %5$s 2>&1'; $cmd = sprintf( $cmd, $device, $resolution, ( $frame + 1 ), escapeshellarg( $output_file ), escapeshellarg( $file ) ); exec( $cmd, $stdout, $return );
However, you are not getting to that code because the
mla_handle_thumbnail_sideload()
function has an Imagick check:if ( ! class_exists( 'Imagick' ) ) { return self::_mla_error_return( 'Imagick not installed', __LINE__ ); }
The Ghostscript function does the basic PDF to image conversion. The ImageMagick/Imagick function does the resizing, compressing, PNG/JPG formatting and conversion of the PNG transparent layers to JPG white background.
- Do you get PDF icons or broken image links for your
- The topic ‘PDF Thumbnail generation not working’ is closed to new replies.