Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript
branch: master

README.markdown

About

For GET requests, dynamically crops and resizes image using ImageMagick convert command. And, serves the resized image.

The following crops 1:2 rectangle at center of some/image.jpg. And resizes the crop to 10x20:

GET /some/image.10x20.jpg

You can specify where to crop other than center. The following crops at the top (north).

GET /some/image.10x20n.jpg

You can specify crop size in percentage (defaults to 100%):

GET /some/image.10x20n.70.jpg

would crop 1:2 rectangle that'll fit about 70% of original image.

Other parameters:

Parameter Crops At Example Comment
Center GET /some/image.10x20.jpg Not specifying a parameter crops at center.
n North GET /a/b.100x400n.jpg
s South GET /a/b.100x400s.jpg
w West GET /a/b.100x400w.jpg
e East GET /a/b.100x400e.jpg
nw NorthWest GET /a/b.100x400nw.jpg
ne NorthEast GET /a/b.100x400ne.jpg
sw SouthWest GET /a/b.100x400sw.jpg
se SouthEast GET /a/b.100x400se.jpg
t No Crop GET /some/image.100x400t.jpg Instead of cropping, some/image.jpg is resized to fit in 100x400 rectangle.

Example

Quickstart

Run

node src/main.js

Configure

cp src/settings.js src/settings.local.js
vim settings.local.js

Example settings.local.js:

module.exports = {
    port: 8081,
    srcDir: '/var/www',
    destDir: '/var/cache',
    convertcmd: '/usr/local/bin/convert'
}
Something went wrong with that request. Please try again.