Three months ago, I developed a custom module for a client. The goal was simple: get sharper and lighter images on their PrestaShop store. The module has been running in production without issues ever since, so I decided to adapt it for the PrestaShop core.
Result: PR accepted in 24 hours and integrated into the PrestaShop 9.2 milestone.
The Initial Problem
PrestaShop uses the GD library by default for image processing. While functional, GD has several limitations:
- Average resize quality: the default algorithm sometimes produces blurry images
- No native AVIF support: the most performant modern web format wasn’t available
- High memory consumption: problematic for stores with many products
Additionally, a community request for ImageMagick support had existed since 2020, with no official response.
The Technical Solution
My Pull Request brings 4 major improvements in just 576 lines of code across 4 files, with zero breaking changes:
1. Native ImageMagick Support
ImageMagick is the reference standard for image processing. My contribution integrates it natively into PrestaShop with:
// Automatic availability detection
if (extension_loaded('imagick')) {
// Use ImageMagick
} else {
// Fallback to GD
}
No configuration needed: if ImageMagick is available on the server, it’s used automatically.
2. Fixed AVIF Support
The AVIF format offers superior compression to WebP while maintaining excellent quality. Support existed partially but was broken. My contribution:
- Fixes AVIF support detection
- Adds AVIF generation via ImageMagick
- Maintains compatibility with older browsers
3. Lanczos Filter for Resizing
The Lanczos filter is recognized as one of the best image resizing algorithms:
$imagick->resizeImage(
$width,
$height,
\Imagick::FILTER_LANCZOS,
1
);
Compared to the default GD algorithm, images resized with Lanczos are:
- Sharper
- Free from compression artifacts
- Visually closer to the original
4. Smart Automatic Fallback
The system automatically detects server capabilities:
- ImageMagick available → used with Lanczos
- Only GD available → transparent fallback
- Neither available → clear error for the administrator
public static function getImageProcessor(): ImageProcessorInterface
{
if (self::isImagickAvailable()) {
return new ImagickProcessor();
}
return new GdProcessor();
}
Concrete Impact for Stores
Before (GD only)
- Sometimes blurry images after resizing
- WebP or JPEG files only
- Variable visual quality depending on products
After (ImageMagick + AVIF)
- Sharper images thanks to Lanczos filter
- 30-50% lighter files with AVIF
- Faster loading = better SEO
- Improved customer experience
Why Contribute to Open Source?
This contribution perfectly illustrates the virtuous cycle of open source:
- A real client need: custom module development
- Production validation: 3 months of trouble-free operation
- Community sharing: adaptation for the core
- Collective improvement: all stores benefit
All of this without paid modules and without complex settings.
Pull Request Details
- Repository: PrestaShop/PrestaShop
- PR #40625: Add ImageMagick support with AVIF and Lanczos filter
- Milestone: PrestaShop 9.2
- Lines modified: 576
- Files modified: 4
- Breaking changes: 0
How to Benefit?
Right Now (module)
If you can’t wait for PrestaShop 9.2, contact me for the standalone module compatible with PrestaShop 8.x and 9.x.
Starting from PrestaShop 9.2
The feature will be native. Just make sure your host offers ImageMagick (most modern hosts do).
To check if ImageMagick is available on your server:
<?php
echo extension_loaded('imagick') ? 'ImageMagick available' : 'GD only';
Conclusion
Contributing to open source means transforming a client development into an improvement for the entire community. This PrestaShop PR proves that a simple solution (576 lines) can have a major impact on thousands of stores.
Want to optimize your PrestaShop store performance? Contact me for a free audit.