Categories
WordPress

WordPress/MAMP: Fixing Cropping Issue

Depending on what development environment you are using, you might encounter errors when cropping images in WordPress. Here is one possible fix for that.

In the front panel of MAMP, check which version of PHP you are running.

If you do not see the PHP version in the front panel, go to the MAMP Preferences and click the PHP tab.

Find the PHP Configuration File to Edit

We will here need to edit a file called php.ini

Depending on which version of MAMP you are using, it will be in a different place.

Possible Location One

Inside the MAMP application folder, open the bin folder.

Then open the php folder. Here you will likely see a number of folders, each named php plus a version number.

Open the one that corresponds to your MAMP’s version of php.

From there open the conf folder and in a text editor like Visual Studio Code open the file php.ini.

Here is the full path to that file for my MAMP, which is on a Mac, using MAMP 6.2.

Skip down to the Edit the Configuration step, below.

Possible Location Two

If you do not find the php.ini file in that location, look in the conf folder in the top level of the MAMP application folder.

There you should see folders with the name php + version number.

Open the file php.ini from the folder corresponding to your php version.

Edit the Configuration

In the opened file, search for imagick using command-f (mac) or control-f (windows).

If you see a semi-colon in front of the line above, remove the semi-colon.

What you have just done is uncomment the line.

This tells PHP to load an extension that will allow WordPress to do a lot of image manipulations.

Once you’ve done that, restart

If imagick is not commented out, you will also need to do the step below the “restart the servers section of this description.

Restart the Servers

Next, go to the MAMP application and restart the servers. You can do this with the STOP / START button in the top right corner.

WordPress should now be able to crop your images.

If It Still Isn’t Working…

If it still isn’t working, check if your version of PHP is 8 or above.

It appears that the PHP 8 configuration on Windows at least introduces another issue.

If the error is still continuing, search the same file for the line

extension=php_gd2.dll

and change it to

extension=php_gd.dll

(In other words, remove the “2”, as in the screenshot below).

Once you’ve made that change, save the file and be sure to restart the servers.

This worked to fix the problem on a Windows version of MAMP January 2022.

Thank you, Valentina, for Windows troubleshooting assistance!

Here’s a very concise Loom video from Suily Tamez Cardenas showing the fix on Windows.