simgr-server

MongoDB-backed image conversion server

Simgr Server

Upload and sideload images, then serve variants using simgr.

  • Built with Koa and composable middleware.
  • Designed to be placed behind a CDN.
  • Converts GIFs to HTML5 videos.
  • Sideload URLs directly.
  • CORS support.
  • Simple REST API.
  • MongoDB-backed.

Aside from that of simgr:

  • SIMGR_MONGODB_URI or MONGODB_URI
  • SIMGR_LOGS_MONGODB_URI - defaults to above
  • SIMGR_CORS_ORIGINS
  • SIMGR_CORS_MAXAGE
  • SIMGR_UPLOAD_TIMEOUT
  • SIMGR_VARIANT_MAXAGE
  • SIMGR_CDN

Optional for basic auth:

  • SIMGR_AUTH_USERNAME
  • SIMGR_AUTH_PASSWORD

Sideloads an image at URL. For example:

PUT /sideload/http://i.imgur.com/cVb8mh3.gif

You can then pass this URL instead of the original url, treating simgr as a proxy server. For example, you might want this to make sure all images are served over HTTPS while validating each image.

Note that simgr actually saves the images. This won't work for URLs that are dynamically generated, but you may use query strings to cache-bust.

Methods:

  • GET - redirects to the image
  • PUT - returns the JSON metadata

POST /upload

Upload an image directly. Note that multipart is not supported. You must upload each image individually. For browser requests, you must use XHR2 and the File API.

You should use Expect: 100-continue.

Methods:

  • POST - returns the JSON metadata

Depending on the accept header, returns the JSON metadata or redirects to the image variant.

You may change the following attributes:

  • format - change an image's default format to jpg or png
  • colorspace - change an image's default colorspace to Grey or sRGB

If json, returns the JSON metadata. Otherwise, returns the image variant.

Returns the image variant.