Skip to content

Instantly share code, notes, and snippets.

@killercup
Created February 7, 2014 18:34
Show Gist options
  • Save killercup/8868864 to your computer and use it in GitHub Desktop.
Save killercup/8868864 to your computer and use it in GitHub Desktop.
Image Processing Server: Resizer and Optimizer

Image Resizer and Optimizer

Idea: grunt-contrib-imagemin as a Service

Tech Stack

  • nginx
  • luajit
  • imagemagick
  • OptiPNG, pngquant, jpegtran and gifsicle

API

/o/:image (GET)

Original image file, untouched.

/i/:image (GET)

Send optimized image or 307 Temporary Redirect to /o/:image.

/r/:h/:w/:image (GET)

Send resized, optimized image.

Server Structure

Store image files in file system (mapping to API routes).

Use nginx' try_files to either send an existing file or generate an new one.

See also

Leafo: Nginx image processing server with OpenResty and Lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment