There has been an error cropping your image

There has been an error cropping your image

Recently I was greeted with the following error on WordPress: There has been an error cropping your image. On Windows PHP 8.0 changed php_gd2.dll to php_gd.dll. That breaks picture cropping functionality in WordPress. How do I know? Funny you should ask! Well, because I ran into this issue soon after upgrading my PHP version to 8.0 on my WordPress blog server. Instead of success, I was greeted with the above-mentioned error message: There has been an error cropping your image.

There has been an error cropping your image

I was researching how to fix this and while I found some possible causes, nothing applied to my situation. So, I kept digging deeper until I stumbled upon the fact that in PHP 8.0 for the GD extension on Windows the DLL file name changed from php_gd2.dll to php_gd.dll. Read up on this on PHP Watch.

Fixing it

I needed to edit the php.ini file in PHP 8 and alter the GD extension changed from php_gd2.dll to php_gd.dll. In its extension-less format change to extension=gd instead of extension=gd2.

As on Linux the GD extension is loaded with the name gd.so, which means that no changes are needed on Linux

What I did was edit the php.ini file under C:\Program Files\PHP\php-8.0.3-nts-Win32-vs16-x64 ( I run the x64 bit version, if you also have the 32 bit version change it there as well).

I changed the following lines:

[PHP_GD2]
extension=php_gd2.dll

to

[PHP_GD]
extension=php_gd.dll

I saved the file and that fixed it. No need even to restart IIS or the web site, that was it. I could crop my files again!

Conclusion

It’s the small things that get you. In this case just a small detail, that might also trip you up. I just hope that this helps some of you out there. The good news is it was fixed quickly, and it was the first issue I had since upgrading to PHP 8.0.3. So far, so good.

Leave a Reply, get the discussion going, share and learn with your peers.

This site uses Akismet to reduce spam. Learn how your comment data is processed.