https://github.com/erf/node-resize
An image resize server built on node.js and sharp
https://github.com/erf/node-resize
image-resize microservice nodejs resize
Last synced: 6 months ago
JSON representation
An image resize server built on node.js and sharp
- Host: GitHub
- URL: https://github.com/erf/node-resize
- Owner: erf
- Created: 2021-08-23T10:05:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-30T21:18:39.000Z (almost 3 years ago)
- Last Synced: 2025-09-25T02:55:34.236Z (6 months ago)
- Topics: image-resize, microservice, nodejs, resize
- Language: JavaScript
- Homepage:
- Size: 488 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-resize
An image resize server built using [Node.js](https://nodejs.org), [sharp](https://github.com/lovell/sharp), [AWS S3](https://aws.amazon.com/s3/) and [koa](https://koajs.com/)
## How it works
1. we receive `multipart/form-data` requests at `api/image`
2. images are resized using `sharp` to a set of configured `sizes`
3. images are uploaded to an `AWS S3` bucket using streams
4. we return a `JSON` [response](#response) with URLS and sizes
## Config
We use [node-config](https://github.com/lorenwest/node-config) to configure
`AWS`, sizes and more.
### Example
```javascript
{
port: 1337,
bucket: 'images',
s3: {
apiVersion: '',
region: '',
accessKeyId: '',
secretAccessKey: ''
},
sizes: [[84, 84], [172, 172], [320, 320], [640, 640], [1024, 1024]],
keep_original: false,
}
```
## Response
The response is an `JSON` array per image with links and sizes of all the resized
images.
### Example
```javascript
[{
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"
}],
}]
```
## Test
See `test/README.md`
## Contribute
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 !