One of my clients was facing issues uploading and editing images in WordPress. The actual upload passed off successfully, but once added to the media library, he couldn’t rotate, crop or scale the image.
As soon as he opened the image attachment page, he saw an error saying “Image rotation is not supported by your web host” and when he went to scale the image, he saw the error “Unable to create new image”. I asked him to go back to the Edit Image page and see if he could see a box called ‘Thumbnail Settings’. He couldn’t. And at that point I new exactly what the problem was.
The GD Image Library
The GD graphics library works with PHP to allow us to dynamically manipulate images. Without it, we can do all the basic tasks such as uploading them, and adding them to our blogs, but we can’t physically alter or adapt them. Now WordPress needs that functionality right out of the blocks. This is because as soon as we upload an image to WordPress, it tries to generate thumbnails. This is a great feature of WordPress that allows it to serve images of different sizes cutting down server load and improving page speed. Without the GD library, WordPress has to give up.
So what do I need to do?
So how do we get it up and running? If you are hosting your website with a hosting provider, you will most likely need to open a support ticket with them and ask them to install the GD library on your server. If you are hosting your own site, log in to your server and type in:
php7.0 -i | grep -i gd
This will tell you if the GD graphics library is installed and enabled. You should see something like the image above. If not, you will need to install it. Assuming you are using PHP version 7, type the following into the command line:
sudo apt-get install php7.0-gd
and then restart the web server with something like
service apache2 restart
Now, simply reload your web browser and try uploading the image again. Congratulations! You can now dynamically manipulate images from within WordPress.