If you’re having trouble with uploading images to WordPress (or other PHP frameworks) and seeing blank spots where images should be, you may need to be sure that LibGD is installed. Check your Apache or Nginx logs for fatal PHP errors which occur when trying to call undefined functions, for example:
- PHP Fatal error: Call to undefined function imageconvolution()
- PHP Fatal error: Call to undefined function imagerotate()
- PHP Fatal error: Call to undefined function imagecreatefromjpeg()
- … and other newer GD functions
Here’s an example I gathered from an Nginx log after attempting to rebuild some thumbnails in WordPress using the AJAX Thumbnail Rebuild plugin:
# Examples from /var/log/example.com-error.log FastCGI sent in stderr: "PHP message: <strong>PHP Fatal error: Call to undefined function imageconvolution()</strong> in /srv/www/example.com/wp-content/themes/my-theme/whatever.php on line 778" while reading response header from upstream, client: 123.456.789.0, server: example.com, request: "POST /wp-admin/async-upload.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com", referrer: "http://example.com/wp-admin/media-new.php"
So, let’s fix it!
Even if you’re on the latest Ubuntu 14.04, you may find yourself in a situation where your installed version of PHP was not compiled with libgd, or it is not installed via your package manager. In that case, it’s easy to install! For the most part, you shouldn’t have to recompile PHP, so try installing/updating libgd using your package manager.
From the libgd FAQs page:
If you want gd for a PHP application, just do (for Fedora):
yum install php-gd
Or, for Red Hat Enterprise Linux or CentOS:
service httpd restart
If your system is Debian based (Debian/Ubuntu/…) then you need to install php5-gd package:
apt-get install php5-gd