ShortPixel ImageAPI Optimize Processor is a custom Drupal module that integrates the ShortPixel POST-Reducer API as an optimization processor for the ImageAPI Optimize module.
The processor automatically optimizes images generated by Drupal Image Styles by uploading the generated file to ShortPixel and overwriting only the generated image style file, while keeping the original source image untouched.
The module fully respects Drupal’s image handling architecture and Drupal best practices.
The processor supports all official ShortPixel compression strategies:
- Lossy – Best balance between image quality and file size. Recommended for most websites.
- Glossy – High-quality compression with minimal visual loss. Ideal for photography and premium visuals.
- Lossless – Pixel-perfect optimization with no visual changes. Best for technical images and graphics.
The compression mode can be selected directly from the ImageAPI Optimize processor configuration.
- Drupal generates an image using an Image Style
(the image is stored under the/stylesdirectory) - ImageAPI Optimize invokes the ShortPixel processor
- The generated image is uploaded to ShortPixel via the POST-Reducer API
- The processor polls the API until optimization is complete
- The optimized image replaces the generated Image Style file
- The original image remains unchanged, as required by Drupal standards
For a deeper technical explanation, see the inline documentation in ShortPixel.php.
- Core logic is implemented in
ShortPixel.php - Module structure follows ImageAPI Optimize processor conventions
- Implementation is inspired by the existing TinyPNG processor
- Extensive logging is used for debugging and validation
- On any API or processing error, the original generated image is preserved to avoid rendering issues
- The first render of an image may be slower due to the external API call
- AVIF or WebP images may occasionally be larger if the source image is already highly optimized
- The processor is designed to fail gracefully and never block page rendering
- Place the module in
/modules/custom/imageapi_optimize_shortpixel - Ensure the ImageAPI Optimize module is installed and enabled
- Enable the module via the Drupal admin UI or Drush
- Configure the ShortPixel processor and API key under ImageAPI Optimize settings
GNU General Public License (GPL)
Same license as Drupal core and contributed modules.