The Wayback Machine - https://web.archive.org/web/20210117151956/https://github.com/saml/nodejs-resize-image
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

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'
}

About

No description, website, or topics provided.

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.