I’m running Bitnami’s WordPress on a Microsoft Azure Ubuntu machine. It seems the default setup does not support the WordPress 4.7 feature to automatically generate PDF thumbnails on upload.
This page explains that you need ImageMagick, Imagick, and Ghostscript and suggests the following to install on Ubuntu:
sudo apt-get update
sudo apt-get php7.0-imagick
Another site, maybe this one, showed how to do it without referencing the PHP version:
sudo apt install imagemagick
That’s what I did. Lots of packages and dependencies were installed. I rebooted the server. Still no thumbnails created, not even visible in the Uploads folder. And when I run this:
php -r 'phpinfo();' | grep imagick
nothing is returned
Okay, the article also mentions installing the Imagick PHP extension:
sudo apt install php-imagick
But that didn’t install anything.
This article mentions enabling imagick.so in the php.ini file. So I edited /opt/bitnami/php/etc/php.ini, uncommenting extension=imagick.so
, and restarted the services (sudo /opt/bitnami/ctlscriph.sh restart
).
Now, php -r 'phpinfo();' | grep imagick
returns this:
imagick
imagick module => enabled
imagick module version => 3.4.3
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0
So I guess it’s working? But still no thumbnail on upload.
This thread mentions the “PDF thumbnails support test plugin”, which I finally found here. After manual installation, Tools > PDF Thumbnails Support Test shows this:
I tried disabling all plugins as suggested. Still no thumbnails.
That same thread mentioned editing ImageMagick’s policy.xml, I tried commenting out the PDF line in /etc/Imagemagick-6/policy.xml, but that didn’t help.
I tried a manual PDF to PNG conversion at the command line following this StackOverflow question. Didn’t work:
convert -density 300 -depth 8 -quality 85 temp.pdf temp.png
gs: /opt/bitnami/common/lib/libtiff.so.5: no version information available (required by /usr/lib/x86_64-linux-gnu/libgs.so.9)
gs: symbol lookup error: /usr/lib/x86_64-linux-gnu/libgs.so.9: undefined symbol: FT_Property_Set
.convert.bin: no images defined `temp.png' @ error/convert.c/ConvertImageCommand/3258.
Looks like some kind of Ghostscript installation or configuration error?
The thread mentions the GS Only PDF Preview plugin. Installed that and immediately got the message “Warning: no Ghostscript! The plugin “GS Only PDF Preview” cannot determine the server location of your Ghostscript executable.”
Maybe it’s a permissions thing? ghostscript –h
returns lots of stuff, so the executable is obviously in the path.
I was able to fix it by making sure Ghostscript and ImageMagick are installed, the Imagick PHP module is installed and by changing the Ghostscript policy following these steps:
https://wordpress.org/support/topic/pdf-thumbnails-no-longer-being-generated/page/2/#post-14600658