• Resolved marclang

    (@marclang)


    I needed to deploy this Plugin on a fairly outdated server, which did not support the imagick extension. Since the current version does *not* check if imagick is actually installed, it would simply crash.

    Here’s a quick fix to first check for the presence of imagick before trying to generate the png image:

    function getCoverImageUrl($doc) {
    		   $filename = FILE_CACHE_DIR . $doc->id . ".png";
    		   if (file_exists($filename)) {
    		      return FILE_CACHE_URL . $doc->id . ".png";
    		   }
    		   $filenamepdf = FILE_CACHE_DIR . $doc->id . ".pdf";
    		   if (!file_exists($filenamepdf)) {
    		      return null;
    		   }
    		   // PATCH TO HANDLE NON-INSTALL IMAGIC EXTENSION
    		   if (!extension_loaded('imagick')) {
            			return null;
    		   }
    		   // PATCH END
    
    		   // generate png ...
    		   $im = new imagick($filenamepdf."[0]");
                       $im->resampleImage (10, 10, imagick::FILTER_UNDEFINED,1);
                       $im->setCompressionQuality(80);
                       $im->setImageFormat('png');
                       $im->writeImage($filename);
                       $im->clear();
                       $im->destroy();
    		   return FILE_CACHE_URL . $doc->id . ".png";
    		}

    Maybe this is useful enough to include it in the next update?

    Cheers,

    -m

    https://www.ads-software.com/plugins/mendeleyplugin/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Small patch to getCoverImageUrl to handle missing imagick library’ is closed to new replies.