Image Compressor resizes images in the browser before they are uploaded, so the server receives a file that already fits the field's maximum dimensions. It uses the Compressor.js library.
It is meant for hosts where server-side resizing is unreliable. On some platforms, large originals exceed memory or upload limits, or GD or ImageMagick fails to scale them, often without an error. Resizing on the client avoids those failures and reduces upload time and bandwidth.
How it works
- The module watches image field widgets that have a Maximum image dimensions setting.
- When a user chooses a file, the browser scales it down to fit within that width and height, keeping the aspect ratio, and re-encodes it at Compressor.js's default quality (0.8).
- The resized file then replaces the original in the file input, and Drupal's normal AJAX upload runs. Server-side validation still applies.
- Images already within the limits are left alone. If re-encoding would produce a larger file, the original is kept.
- Multiple-file uploads are supported. All files are processed before the upload starts.
Requirements
- Drupal 11.2 or later, or Drupal 12.
- Core Image module.
- Compressor.js is bundled with the module. No separate library download is needed.
Installation and use
- Install the module as usual:
composer require drupal/image_compressor, thendrush en image_compressor. - On each image field that should be resized, set Maximum image dimensions in the field settings, for example
2400 × 2400. - No other configuration is needed. Widgets without a maximum are not affected.
How this module is built
Changes to this module since 2026 were drafted with an AI coding assistant (Claude Code). The maintainers review, test and take responsibility for every change, and the tests and code checks run on drupal.org's CI. Contributions follow Drupal's policy on the use of AI when contributing.
Supporting this module
Developed and maintained by Tyler Brown Cifu Shuster of FivePaths, LLC. Development sponsored by FivePaths.
Project information
- Project categories: Content editing experience, Media
19 sites report using this module
- Created by tbcs on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.

