Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Image Compressor

Security covered Under active development 25 sites

This module uses the compressor.js library to enforce image size limits directly in the user's browser. This is particularly helpful for websites hosted on servers that cannot handle large image files or fail to resize them automatically.

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

  1. Install the module as usual: composer require drupal/image_compressor, then drush en image_compressor.
  2. On each image field that should be resized, set Maximum image dimensions in the field settings, for example 2400 × 2400.
  3. 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.

Drupal 11 · not 10

Ask your assistant about Image Compressor

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • image Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Oct 2023
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0 Stable 11 Oct 9, 2026
1.0.x-dev Dev 10–11 Oct 11, 2023