Skip to content

Resize images before they are uploaded.

Image Compressor scales images down in the browser to the image field's maximum dimensions, so the server receives a file that already fits.

For Drupal 11.2+ and 12 · Core Image module · Compressor.js

The same 6012 by 4000 pixel photo uploaded to two image fields on the Create Article form. The field without a maximum stores the 8.86 MB original. The field with a 2400 by 2400 maximum stores a 2400 by 1596 pixel copy of 187.84 KB.

For sites on hosts where server-side resizing is unreliable: large originals exceed memory or upload limits, or the image toolkit fails to scale them. Resizing in the browser avoids those failures and reduces upload time and bandwidth.

What it does

  • Reads the Maximum image dimensions of each image field and passes them to the field's file input.
  • When a JPEG, PNG or WebP image larger than the maximum is chosen, scales it down in the browser with Compressor.js, keeping its aspect ratio and file type.
  • Starts Drupal's normal upload once the images are resized. Server-side validation still applies.
  • Leaves images that already fit, other file types, and other file fields alone.

Requirements

  • Drupal 11.2 or later, or 12.
  • The core Image module.
  • Compressor.js 1.3 or later in the libraries directory. See Installation.

There are no settings. See Configuration.