npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

directus-extension-image-upload-resizer

v2.1.4

Published

Automatically lighten and resize large images during upload

Readme

Image Upload Resizer

Directus extension to automatically lighten and resize large images during upload.
Formats are automatically converted into webp to be more light and web proof and the sizes are decreased if the image is larger than the maximum preset limits.
That can be a helpful tool to optimize server space.

This extension works out of the box without the need of settings, anyway you can tune it properly with the following environment variables.

Settings

The extension by default uses three env variables:

  • EXTENSIONS_IMAGE_UPLOAD_RESIZER_QUALITY = 73
  • EXTENSIONS_IMAGE_UPLOAD_RESIZER_MAXSIZE = 1920
  • EXTENSIONS_IMAGE_UPLOAD_RESIZER_KEEP_METADATA = false which respectively set the quality, the maximum size and the keeping of metadata* (EXIF/GPS) about the new converted images.
    * Metadata cannot be carried over during HEIC conversion (read "Notes and caveats" section below).

Directus also uses the following env variables to manage images:

  • ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION = 6000 the maximum pixel size (width/height) that is allowed to be transformed*.
  • ASSETS_TRANSFORM_TIMEOUT = 7500ms max time spent trying to transform an asset*.
    * Variables not applied to HEIC source files (read "Notes and caveats" section below).

If you consider working with particularly large images (professional photography, high-resolution scans), I recommend increasing ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION and adjusting ASSETS_TRANSFORM_TIMEOUT accordingly; otherwise, those files will simply be discarded by the hook (safely, but still not converted).
Keep in mind that setting this values too high increases the risk of high memory and CPU usage for particularly large images.
Read more here.

To customize the previous values, you have to add/set these env variables on your Directus instance (and then restart it).

HEIC/HEIF support (new feature)

iPhone photos (.heic) are HEVC-encoded: Directus refuses to transform them (they are not in its internal SUPPORTED_IMAGE_TRANSFORM_FORMATS whitelist) and the prebuilt sharp/libvips cannot decode HEVC either (AV1-only build, patent reasons). This extension therefore:

  1. fetches the original file untouched via AssetsService (storage-agnostic);
  2. decodes it with heic-decode (libheif compiled to WASM, bundled into dist/index.js — no server changes needed);
  3. resizes and encodes to WebP with the sharp instance already installed by Directus (marked as external in extension.config.js).

Notes and caveats

  • This extension actually resizes and converts images from the following formats only: jpeg, png, webp, tiff, heic, heif.
  • The code was heavily rewritten to fix crashing bugs during upload and to improve performances.
  • The actual version is tested working with Directus 12.
  • EXTENSIONS_IMAGE_UPLOAD_RESIZER_KEEP_METADATA has no effect on HEIC sources: the WASM decoder outputs raw pixels, so EXIF/GPS metadata cannot be carried over. Orientation is preserved (libheif applies it during decode).
  • ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION and ASSETS_TRANSFORM_TIMEOUT do NOT apply to the HEIC path (it bypasses Directus' transform pipeline); decoding a 12 MP HEIC to raw RGBA takes ~50 MB of RAM for a short time.

Credits

To Christian Fuss