Support » Fixing WordPress » PDF Thumbnails / Ghostscript / PHP 8

  • Resolved idad5


    I recently upgraded my local dev server (xampp on windows 10) to PHP 8 (8.02).

    While I was at it I also resolved to get Imagick working and ghostscript which I had not done before. After some / a lot of digging I got Imagick / running as PHP module (confirmed by phpinfo() etc) and ghostscript is running too.

    I did all this mostly to get my dev-server to generate PDF thumbnails. It does not.

    So I dug deeper:

    The ‘Debug Media’ plugin reports that ImageMagick is installed (Version 7.0.11-1 Q16 x64 2021-02-21) also hat Ghostscript Version 9.53.3 is present. BUT
    Active Editor is WP_Image_Editor_GD. As far as I understand that shouldn’t be the case if ImageMagick is present.

    The ‘PDF Thumbnails Support Test’ plugin reports:

    ImageMagick: Installed
    Imagick: Installed
    Ghostscript: Not Installed
    WordPress >= 4.7: Installed

    That’s strange but probably due to different ways both pluings check for the existence of the modules / functionality. (In fact I’m quite sure by now)

    I feared that somehow there was a problem with my ImageMagick installation so I searched around for an easy way to get WP to use ImageMagick (preferably with some lines in function.php). But I only found that wordpress automatically uses ImageMagick over GD if present – mine does not.

    What I also found was an other plugin (I normally don’t use plugins it avoidable at all) ‘ImageMagick Engine’ and for testing purposes I installed it. This plugin found the ImageMagick PHP-module and was able to use it just fine…

    To clarify: My question is not about plugins, I used them just to find out information I wasn’t able to see any other way. For starters I just want my wordpress installations on my server to be able to render PDF thumbnails as of WP 4.7.

    ImageMagick is present and working on my system but wordpress does not use it. Might that be related to PHP8 (wordpress support at, the time of writing this, claims beta support for PHP 8)
    Is there a way to force wordpress to use ImageMagick over GD?

    Or am I doing / understanding something totally wrong?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dion


    The current version of the PECL Imagick extension (3.4.4) is not compatible with PHP 8. If you want to use it, you’ll need to revert to PHP 7.4. The source code in the extension’s GitHub repository is compatible with PHP 8, but it must be compiled.

    Thread Starter idad5


    @diondesigns: That is true, but only in part.

    Thank you for you answer. There is an (unofficial) compiled DLL version available that works very well with PHP 8. The problem with this DLL and according to my research also with other official versions is that it reports @PACKAGE_VERSION@ as version instead of a valid version number. The problem seems not to be windows exclusive, I also read about similar problems on MacOS.

    I don’t have a clear idea yet which versions are faulty but it seems to affect several.

    While the problem originates obviously from PELC one might also argue that the check for a version greater than ‘2.2.0’ in the WP_Image_Editor_Imagick calss is less than optimal. We learned the hard way in years of browser sniffing that checking for feature is almost ever the better way tp go.

    So I would propose to that reworking the WP_Image_Editor_Imagick::test method could use a better approach after about nine years.



    I edited the following lines in the php_imagick.h file to change the version:

    #define PHP_IMAGICK_VERSION    "8.0.0"
    #define PHP_IMAGICK_EXTNUM     80000

    After compiling, phpinfo() and phpversion('imagick') both correctly report the Imagick version as 8.0.0. Perhaps the person who built the “unofficial” DLL didn’t do it correctly? That’s a distinct possibility since the build files are for automake/configure and not for cmake.

    Also note that the current source contains a fix for the MacOS/homebrew issue.

    In any case, since you want to test GhostScript, the best solution for now is to revert to PHP 7.4.

    Thread Starter idad5


    @diondesigns thanks for your info.

    Reverting to PHP 7.4 is not an option for me right now. Also I won’t get into compiling my own DLL soon.

    I’m an architect by education and I started programming at 13 – nearly 40 years ago. My business nowadays is mainly designing, building and maintaining websites and related projects. Also I’m a father of three and I shouldn’t take the time to writ such a long comment, but I somehow feel like it right now.
    So I do consulting, designing (including a little photography and video-production now and than) I program PHP work with basic SQL, do typescript and teach CSS… and mange to stay up to date with all things web more or less successfully since 1995.
    Nothing spectacular, but all in all enough challenge for my elderly brain.
    For several reasons my main machine is a windows box (need one to see what most of my users see). I also have a MacBook Pro, iPads, an iPhone and some older android devices for testing. I tried to have a Linux-box around for some time some years ago, but it just added to my workload of keeping too much devices up to date instead of getting some work done.
    Until the early days of WordPress I used IIS for local development but at some point I had to switch to Apache (.htaccess) so I decided to go with XAMPP.

    Over time I had to make my computer accessible for my clients from outside with dyndns (balancing security against comfort etc.) and also make XAMPP work with letsencrypt, running different PHP versions for different projects etc.

    Problem with XAMPP is, that there are no up- or downgrades, if you want a new PHP version you have to do a new install and migrate all your old individual tweaks. As I do that only once in maybe 9 to 10 month automating that isn’t really worth it, also I’m still considering changing the system at some point to a better all around solution which I haven’t found yet.

    I was really looking forward to PHP 8 as I’m a great fan of strong typing since AS3 (yes I know…) and have already written several classes that way. So going back to 7.4 would break that. PHP 8 is stable for quite a while now and I’ll stay with it, as at some point I have to anyhow also I like it. Running ImageMagick and ghostscript on my own XAMPP is a benefit for my but not a necessity and I’m ok with the way it works for me right now.
    For me and probably for a lot of other people out there ‘perfect’ or even ‘right’ is sometimes not an option, ‘it works’ has to do more often than not.

    I somehow envy you for being able to do what you do, and I very much appreciate what you and other geniuses do for the community with your work. And I feel sorry when I use it in a ‘bad’ way but I have to contradict your last statement: For me the best solution for now is to run with my setting and comment out two (obsolete) lines in WP_Image_Editor_Imagick::test

    I wrote all this not only to bore you to death, but in the hopes that maybe some like minded spirits might read that and we could exchange experiences. Have a good day all of you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PDF Thumbnails / Ghostscript / PHP 8’ is closed to new replies.