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.

WorkingHardInIT Blog Maintenance Window & Tools Used

As you might have noticed my blog was down last night for about 1 hour and 45 minutes between 22:20 and 00:10. A bit longer than I wanted but I needed more time do deal with the upgrade of MySQL as part of the routine maintenance I do on my WordPress blog server.

In the environments under my care I take care to take the time to do routine maintenance to avoid falling behind to much in firmware, drivers, patches, etc. This takes some effort but as it helps prevent bigger issues in the long run it’s worth while to do so. I take the same approach with my blog as much as possible. Most of this maintenance goes by without you ever noticing. The windows updates reboots being the exception. WordPress upgrades, plugin upgrades, PHP upgrades, etc. … all go swiftly usually which means I’m pretty well covered there, frequently.

Upgrading MySQL however is always a bit of a time consuming effort and depending on what version you’re upgrading from and to witch one it can actually mean multiple sequential upgrades (5.1 to 5.5.44 to 5.6.25).image

I practiced this upgrade on a copy of the VM in azure to make sure I could handle whatever came up and still I had to deal with some challenges I did not encounter in the test environment. That show that I’m not a full time hard core MySQL guru I guess.

Anyway after getting to MySQL 5.6.25 from 5.5.44 and fixing some issues with TIMESTAMP with implicit DEFAULT value is deprecated (easy fix) and dealing with the error in MySQL Workbench:

An unhandled exception occurred (Error executing ‘SELECT t.PROCESSLIST_ID,
IF (NAME = ‘thread/sql/event_scheduler’,’event_scheduler’,t.PROCESSLIST_USER) PROCESSLIST_USER,t.PROCESSLIST_HOST,t.PROCESSLIST_DB,t.PROCESSLIST_COMMAND,
t.PROCESSLIST_TIME,t.PROCESSLIST_STATE,t.THREAD_ID,t.TYPE,t.NAME,t.PARENT_THREAD_ID,
t.INSTRUMENTED,t.PROCESSLIST_INFO,a.ATTR_VALUE FROM performance_schema.threads t 
LEFT OUTER JOIN performance_schema.session_connect_attrs a ON t.processlist_id = a.processlist_id AND (
a.attr_name IS NULL OR a.attr_name = ‘program_name’) WHERE t.TYPE <> ‘BACKGROUND”
Native table ‘performance_schema’.’threads’ has the wrong structure.
SQL Error: 1682). Please refer to the log files for details.

which I fixed by running run mysqld –performance_schema I’m rocking everything up to date once more.

image

Always have good backups, make exports of your database schema, data and structures in MySQL and have multiple ways out when things go south. In Azure I’m relying on Backup Vault where I protect my virtual machine with schedules backup jobs. I also backup my WordPress with the data via a plug in and export the database via MySQL Workbench.

image

Those dumps are copied out of the VM to where ever I want (Azure, One Drive, home PC, a VM running in AWS …) to make sure I have multiple options to recover.

image

VEEAM FastSCP for Microsoft Azure comes in very handy for this by the way. You might want to check it out if you’re in need of an automated and secure way to get data out of a VM running in Microsoft Azure!