🎉 Get the Insurfin - Insurance Service HTML5 Template for FREE - Offer Ends Soon!
Easy fixing of PHP's gd extension error

Why You Need the PHP gd Extension

The PHP GD extension is essential for image manipulation tasks, such as generating charts, resizing images, and creating thumbnails dynamically on your website or application.

If you are using PhpSpreadsheet, the gd extension is required to handle image-related functionalities in spreadsheets, such as inserting or processing images inside .xlsx files.

Without the gd extension, you may encounter errors like this.

php gd extension missing error

gd Extension Is Missing Error After Upgrading PHP

Recently, I upgraded my PHP version on the Ubuntu server to 8.2, but the new version did not automatically install the extensions, leaving PHP 8.2 without gd. This caused my deployment pipeline to fail, displaying the missing gd extension error during CI/CD deployments.

✅ Verify that gd is enabled

Run the following command to verify gd status.

php -m | grep gd

If enabled, you will see

gd

Check PHP gd extension status

Alternatively, you can run the following command.

php -i | grep "GD Support"

and it should return:

GD Support => enabled

If you do not see these outputs, you need to install the gd extension for your PHP version.

✅ Install the gd extension for PHP 8.2 on Ubuntu

Run the following command, and it will install the gd extension for PHP 8.2, allowing your application and pipelines to handle image functionalities without errors.

sudo apt install php8.2-gd

It will take a few minutes to complete the full installation process.

🚀 Bonus Tips:

To ensure PhpSpreadsheet works without extension-related issues, run:

sudo apt install php8.2-ctype php8.2-fileinfo php8.2-mbstring php8.2-gd php8.2-xml php8.2-zip php8.2-iconv

These extensions are often needed for spreadsheet operations, file handling, and multi-byte string support.

✅ Verify currently enabled extensions

PHP by default activates some of these extensions (like ctype, fileinfo, iconv, simplexml, and dom), but explicitly installing them ensures no environment mismatch. Run the following command to check the output.

Currently enabled PHP extensions

If you need advanced image manipulation (transparent PNGs, high-quality resizing, etc.), you can install Imagick:

sudo apt install php8.2-imagick

You are now ready to continue using PhpSpreadsheet and other PHP libraries requiring gd without errors on your Ubuntu server with PHP 8.2.

Total 0 Votes
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

Back To Top
Premium WordPress Themes and Plugins By xenioushk
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.