GS Only PDF Preview
The plugin pre-empts the standard WordPress 4.7/4.8 PDF preview production process (which uses the PHP extension Imagick ) to call Ghostscript directly to produce the preview. This means that only Ghostscript is required on the server. Neither the PHP module Imagick nor the server package ImageMagic
The plugin pre-empts the standard WordPress 4.7/4.8 PDF preview production process (which uses the PHP extension Imagick ) to call Ghostscript directly to produce the preview.
This means that only Ghostscript is required on the server. Neither the PHP module Imagick nor the server package ImageMagick is needed or used (though it’s fine if they’re installed anyway, and if they are they’ll be used by WP (unless you override it) to produce the intermediate sizes of the preview).
Background
The plugin was prompted by the WP_Image_Editor_Imagick_External demonstration class uploaded to the WP Trac ticket #39262 Fall back to ImageMagick command line when the pecl imagic is not available on the server by Hristo Pandjarov , and by the wish to solve the WP Trac ticket #39216 PDFs with non-opaque alpha channels can result in previews with black backgrounds. , which particularly affects PDFs with CMYK color spaces (common in the print world).
The plugin by-passes (as far as PDF previews are concerned) #39216, and also by-passes the related issue #39331 unsharpMaskImage in Imagick’s thumbnail_image is not compatible with CMYK JPEGs. , as the preview JPEGs produced directly by Ghostscript use sRGB color spaces.
Limitations
The plugin requires the PHP function exec to be enabled on your system. So if the PHP ini setting disable_functions includes exec , the plugin won’t work. Neither will it work if the suhosin security extension is installed and exec is either not whitelisted or is blacklisted .
Also, the plugin is incompatible with the PHP ini setting safe_mode , an old (and misnamed) setting that was deprecated in PHP 5.3.0 and removed in PHP 5.4.0.
Security
The plugin uses the PHP function exec to call Ghostscript as a shell command. This has security implications as uncareful use with user supplied data (eg the upload file name or the file itself) could introduce an attack vector.
I believe these concerns are addressed here through screening of the file and its name and escaping of arguments. This belief is backed by a bounty of fifteen hundred thousand intergalactic credits to anyone who spots a security issue. Please disclose responsibly.
Performance
Unsurprisingly it’s faster. Crude benchmarking (see the script perf_vs_imagick.php ) suggests it’s around 35-40% faster. However the production of the preview is only a part of the overhead of uploading a PDF (and doesn’t include producing the intermediate thumbnail sizes for instance) so any speed-up may not be that noticeable.