• Resolved thenemal

    (@thenemal)


    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 / Preview

    You 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?

    https://www.ads-software.com/plugins/media-library-assistant/

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter thenemal

    (@thenemal)

    I have added the following lines at the end of my php.ini:

    [Imagick]
    extension=imagick.so

    The site is working as usual. I get the same error message in MLA when trying to generate the thumbnail of a PDF (Imagick not installed).

    I have a very limited knowledge of PHP, what is the best way to check if the extension is properly installed in PHP? Also do I need to restart something after installing the lines in php.ini?

    TheNemal

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your prompt response and persistence.

    The best way to check is the class_exists() call that MLA is already performing. You can also do a completely stand-alone check that doesn’t need MLA or even WordPress. Create a file called something like phpinfo.php in the root directory of your site, then add this content to that file:

    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
     <p>Calling phpinfo();</p>
     <?php phpinfo(); ?>
     </body>
    </html>

    Then, simply run the file in your browser, e.g., “https://mysite.com/phpinfo.php&#8221;. You will get a great summary of everything PHP-related on the site. If you see an “imagick” section, it’s up and running. If you don’t see that section in the output, something went wrong.

    You may need a different syntax based on how your server is set up. For example, my test system is Microsoft Windows Seven based, and requires:

    [PHP_IMAGICK]
    extension=php_imagick_zts.dll

    As I said, the first time I tried this it didn’t work. I reported the failure to my host’s tech support and they added the Imagick modules to the server, which solved the problem. Let me know if that helps. Good luck!

    Thread Starter thenemal

    (@thenemal)

    Thank you for the information. So Imagick is not installed in PHP. I keep pushing my hosting company to compile it but for now they advise to call ImageMagick functions differently and is suggesting the following example:

    <?php
    
    function resizeImage($image_path, $new_width, $new_height) {
    if( !class_exists("Imagick") ) {
    $rel_upload_dir = "uploads/"; //Your
    $root = $_SERVER["DOCUMENT_ROOT"];
    $root_upload_dir = $root . "/portal/uploads";
    
    //Get the root path for the images..
    $old_img = str_replace($rel_upload_dir, $root_upload_dir, $image_path);
    $new_img = str_replace(".jpg", "_thumb.jpg", $old_img);
    
    //Generate the command..
    $cmd = "/usr/bin/convert {$old_img} -resize {$new_width}x{$new_height} {$new_img}";
    
    $return = null;
    
    //Execute the command
    exec($cmd, $return, $return);
    
    $new_img_dir = str_replace($root_upload_dir, $rel_upload_dir, $new_img);
    
    return new_img_dir;
    }
    else {
    //Use Imagick
    }
    }

    What do you think?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for working with your hosting company on this and for taking the time to post their suggested alternative. resizing is just one of several operations MLA uses Imagick for, and I will have to see if all of them can be done with the command-line “convert” alternative. I will certainly look into it.

    Even if I can resolve this issue for MLA, it will not allow WordPress to use Imagick/ImageMagick for its own intermediate size generation and image editing functions, and WordPress will not accept the “convert” alternative. That’s another reason to pursue the Imagick path.

    Thanks for your continued help with this topic!

    Thread Starter thenemal

    (@thenemal)

    Hello David,

    I have escalated as much as possible, they won’t allow me to recompile PHP with Imagick on my shared hosting plan, in order to keep the shared resources under control.

    Now regarding your second paragraph: my WordPress is generating the 3 sizes of thumbnails as expected + I have a plugin to cap the size of the main picture (Imsanity) that works just fine. Also resizing or cropping the image with the native image editor works just as expected. I am also successfully using a plugin to control and resize my thumbnails (Post Thumbnail Editor)… all of this without Imagick. Not sure if these features are what you are referring to. All of this works for pictures only. Not video or pdf.

    TheNemal

    Plugin Author David Lingren

    (@dglingren)

    Thank you for all your efforts with the hosting company; I know it’s time consuming and frustrating. I regret that they won’t provide Imagick support, despite what their own web site clearly states.

    Yes, those are the features I mentioned. WordPress will use Imagick/IMageMagick when it is available, and will fall back to the older GD support if required. WordPress claims that GD gives lower quality results and lower performance, which is why they put in the work required to offer the Imagick/IMageMagick alternative.

    As I said, I will investigate the “convert” alternative and post an update here when I have something to report.

    Thread Starter thenemal

    (@thenemal)

    Well that’s very nice from you. I am looking forward to your updates.

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘PDF Thumbnail generation not working’ is closed to new replies.