Giter Site home page Giter Site logo

static-crop's Introduction

static_crop

NodeJS web server thats crops and / or resizes images from the Zooniverse's static media server

What is it?

A HTTP wrapper over image magic that offers crop, resize and crop_resize functions on the image specified by a query param u. Note: the ?u= query param should be a path suffix from the specified static server hostname. E.g the following media resource u query param:

  • http://zooniverse-static.s3-website-us-east-1.amazonaws.com/panoptes-uploads.zooniverse.org/production/subject_location/90a3b642-55e2-4583-a4fb-2f0abeb5b285.jpeg
  • u=panoptes-uploads.zooniverse.org/production/subject_location/90a3b642-55e2-4583-a4fb-2f0abeb5b285.jpeg

/crop route

Crop route can be specified in two formats and all dimensions are in pixels.

  1. Params are: w x h dimensions at the x, y offset.
  1. Params are part of the url path: /w/h/x/y/u, note the path to the image (u) should be url encoded, e.g.

/resize route

Resize the image, dimensions are in pixels and can be overwritten by o url. See http://www.graphicsmagick.org/GraphicsMagick.html#details-resize.

Params are: w x h dimensions and an options o to specify the resize options mentioned above.

/resize_crop route

The image should be resized to fill the dimensions as much as possible, so cropping may be necessary. For example, if the image is 200x800, and you want to resize to 100x100, the image would first be resized to 100x400, and then the height would be cropped down to 100.

Params are: w x h dimensions.

/montage route

Tile several images together to create a multi-image subject image. Requires at least two images

Params are: w for tile width, mw for max desired width (for the final image)

Require

Requires GraphicsMagick and (for now) ImageMagick CLI tools to be installed:

Debian/Ubuntu:

apt-get install imagemagick graphicsmagick

OSX:

brew install imagemagick or port install ImageMagick

Install and run

npm install
npm start
#memory issues? defaults to 512mb and 1GB respectively
#limits are 1.4GB in 32-bit node and 4GB in 64-bit node
node --max_old_space_size={size in mb} server.js

Env vars

NODE_STATIC_SERVER || "http://zooniverse-static.s3-website-us-east-1.amazonaws.com/"
NODE_PORT || 8080
NODE_ENV || "development"
NODE_DEBUG || false

Notes

  • Uses docker (cron & tmpreaper) to clean up the media in the /img directory. See the docker/static_crop_cron tabfile for more details.

Credits

Inspired by the good work from Philmod, https://github.com/Philmod/node-resize-image-server

static-crop's People

Contributors

adammcmaster avatar camallen avatar itsravenous avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.