An image resize server built using Node.js, sharp, AWS S3 and koa
-
we receive
multipart/form-datarequests atapi/image -
images are resized using
sharpto a set of configuredsizes -
images are uploaded to an
AWS S3bucket using streams -
we return a
JSONresponse with URLS and sizes
We use node-config to configure
AWS, sizes and more.
{
port: 1337,
bucket: 'images',
s3: {
apiVersion: '',
region: '',
accessKeyId: '',
secretAccessKey: ''
},
sizes: [[84, 84], [172, 172], [320, 320], [640, 640], [1024, 1024]],
keep_original: false,
}The response is an JSON array per image with links and sizes of all the resized
images.
[{
id: "fea4f480-7ce0-4143-a310-a03c2b2cdbc6",
ext: "jpg",
filename: "fea4f480-7ce0-4143-a310-a03c2b2cdbc6.jpg",
url: "http://s3-eu-west-1.amazonaws.com/my-images/0067505f-99db-4770-8fda-df70c8f879e0.jpg"
main: true,
scaled: [{
width: 640,
height: 640,
url: "http://s3-eu-west-1.amazonaws.com/my-images/640x640_0067505f-99db-4770-8fda-df70c8f879e0.jpg"
}, {
width: 320,
height: 320,
url: "http://s3-eu-west-1.amazonaws.com/my-images/320x320_0067505f-99db-4770-8fda-df70c8f879e0.jpg"
}, {
width: 172,
height: 172,
url: "http://s3-eu-west-1.amazonaws.com/my-images/172x172_0067505f-99db-4770-8fda-df70c8f879e0.jpg"
}, {
width: 84,
height: 84,
url: "http://s3-eu-west-1.amazonaws.com/my-images/84x84_0067505f-99db-4770-8fda-df70c8f879e0.jpg"
}],
}]See test/README.md
If you have ideas on how to improve node-resize, please create an issue or a PR.
Let's make the best (and fastest) image-resize server for Node.js !