pardnio/node-image-server

Last updated

NoteThis README was generated by SKILL, get the ZH version from here.



RESIZE ONCE, SERVE FROM CACHE EVERYWHERE!


VersionLicense




A Node.js image resizing server with on-the-fly WebP/AVIF conversion, Nginx and CDN caching, and date-sorted trash

Table of Contents



Features


docker compose up -d · Documentation

  • Four-Tier Caching — Browser, Cloudflare Worker, Nginx proxy_cache, and on-disk cache files intercept requests layer by layer, so each image is processed only once.
  • On-the-Fly Resizing — URL parameters set size, quality, and format (WebP/AVIF/JPG/PNG), defaulting to WebP and shrinking oversized images to a 1024px long edge.
  • Parameterized Cache Variants — Every size and quality combination produces its own cache file, and the Worker keys its cache on the query string, so variants never overwrite each other.
  • Date-Sorted Trash — Deletion moves files into .trash/YYYY-MM-DD/ and returns the new location, making recovery by deletion date straightforward.
  • One-Command Deployment — Docker Compose starts Nginx alongside a PM2-managed Node.js cluster that respawns workers when they exit.

Architecture


Full Architecture

graph TB
    Client[Client] --> Worker[Cloudflare Worker<br>CDN cache]
    Client --> Nginx[Nginx<br>proxy_cache]
    Worker --> Nginx
    Nginx --> App[Express Cluster]
    App --> GET[GET /c/img<br>sharp conversion]
    App --> POST[POST /upload]
    App --> DEL[DELETE /del]
    GET --> Storage[(storage/image<br>upload · cache)]
    POST --> Storage
    DEL --> Trash[(upload/.trash)]
  1. graph TB
  2. Client[Client] --> Worker[Cloudflare Worker<br>CDN cache]
  3. Client --> Nginx[Nginx<br>proxy_cache]
  4. Worker --> Nginx
  5. Nginx --> App[Express Cluster]
  6. App --> GET[GET /c/img<br>sharp conversion]
  7. App --> POST[POST /upload]
  8. App --> DEL[DELETE /del]
  9. GET --> Storage[(storage/image<br>upload · cache)]
  10. POST --> Storage
  11. DEL --> Trash[(upload/.trash)]

License


This project is licensed under the MIT LICENSE.

Author


Just open an issue to share an idea.
node-image-server contributors


©️ 2025 邱敬幃 Pardn Chiu
中文