WordPress There has been an error cropping your image

GD Graphics Library

I was updating my theme with the pretty amazing Twenty Seventeen from WordPress. Attempting to add a site icon it was just… failing. The blue select button in the Media Library would just go grey. When I tried a picture larger than 512×512 pixels I got a step further with the cropping dialogue, but then I’d get…

There was an error cropping your image.

It turns out WordPress needs the php-gd library for image manipulation.

First work out what php version you are running with

php -v

On Ubuntu/Debian hosts with php 5.x run

sudo apt-get install php5-gd

On RedHat/CentOS hosts with php 5.x run

sudo yum install php-gd

You may need to install specific packages like php56-gd for php 5.6. For php 7.x you will need to install php7.0-gd

Finally restart your web server

/etc/init.d/httpd restart

As an aside: I’m regretting my commitment to add an image to every post. What image makes sense with this post? The official logo for GD is 300×230 pixels.