simgr

Image resizing proxy using S3 as a backend

npm install simgr
116 downloads in the last week
150 downloads in the last month

simgr - Simple Image Resizer Build Status

Simgr is a library for your app to manage different variants of your images (basically different sizes). However, instead of the usual batch resizing, Simgr creates each variant on demand. Empirically, this works better on low memory platforms.

Features, Support, and Limitations

  • Generator-based control flow. Meant to be used with co.
  • Meant to be implemented as a module within an app. Does not include any Express middleware or anything.
  • Image validation for HTTP streams
  • Designed for low-memory platforms
  • Colorspace correction when resizing - Only supports sRGB and Grayscale colorspaces
  • Orientation correction
  • Converts GIFs to HTML5 videos
  • sha256s to keep track of your files and avoid duplicates
  • Original images and variants are stored in separate buckets, allowing for better storage controls. Specifically, you should have reduced redundancy and expiration times on your cache bucket to save costs.
  • Requires UNIX 64-bit platforms

See the official Dockerfile for the binaries needed to use this library.

Supported Image Conversions

Input images:

  • JPEG
  • PNG
  • GIF
  • TIFF (if supported by the platform)
  • WebP (if supported by the platform)

Output images:

  • JPEG
  • PNG
  • GIF (only if GIF source)
  • WebP (if supported by the platform)

Output videos (only if animated GIF is the source):

  • WebM (vpx)
  • MP4 (x264)

Theora is not supported as WebM is more widely supported, but adding support is trivial.

Documentation

View the wiki.

Dockerfile

Simgr assumes you have the correct binaries installed. Here's the officially supported Dockerfile that installs all the necessary binaries. This Dockerfile is not included in the repository as simgr is intended to be used as a module, not a standalone app or service.

Note that Docker usage is not required - as long you install the correct binaries on your system, you'll be fine.

Temporary files

Temporary files are stored in the folder simgr.tmpdir. You must clean these files yourself. A helpful utility is visionmedia/reap.

Slow on Dev Machines

Simgr is pretty slow on your home internet connection since on every variant, it downloads the original, resizes it, uploads the variant, then streams it from S3. However, this is meant to be used on AWS hardware (or any cloud infrastructure) where the bandwidth is fast and behind a CDN where this won't happen often. Look at how fast the travis tests take!

License

The MIT License (MIT)

Copyright (c) 2013 Jonathan Ong me@jongleberry.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you