
- Views: 382
- Category: WHM
- Published at: 17 Aug, 2023
- Updated at: 18 Aug, 2023
Integrating the pngquant Command-line Utility for Optimal PNG Compression
The Intervention library stands as a powerhouse in PHP for image management, leveraging the capabilities of both the GD Library and Imagick. While its prowess is undeniable, it falls short with .png images. For instance, a PNG image reduction from 1.3 MB may only reach 1.1 or 1.2 MB, which, considering website optimization and SEO implications, might not be the best outcome. The strength of Intervention is predominantly evident when converting images, especially from .png and jpg to webp format – achieving size reductions as impressive as from 1381.50 KB down to 46.75 KB.
For better handling of lossy PNG compression, the pngquant command-line utility emerges as a top contender. If you’re aiming to harness this utility, you first need to ascertain its availability in your environment. Should you be operating on a VPS, pngquant's integration is straightforward. By inputting pngquant --version into your terminal, an output resembling 2.12.5 (July 2019) should appear. Note: Direct terminal or SSH access is crucial for this step. If on shared hosting, reaching out to your hosting service becomes necessary.
To employ the pngquant library, execute the following:
pngquant --force --output=outputImage.png inputImage.png
Enabling the EPEL Repository:
pngquant is housed in the EPEL repository. Activating this repository is the first step:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
pngquant Installation:
Post EPEL setup, pngquant can be installed with:
sudo dnf install pngquant
Installation Verification:
To ensure a successful pngquant installation, input:
pngquant --version
Once the library is installed, verify if exec is enabled in your environment using:
php -I | grep disable_functions
For those with root or WHM permissions, adjustments to the disable_functions can be made by navigating to MultiPHP Manager, selecting "Edit PHP-FPM", pinpointing the desired section, excluding it from the "Disable Functions" area, and finalizing with an update.
This guide aids in smoothly integrating pngquant and ensuring a robust setup for optimal PNG compression.
0 Comment(s)