Skip to content

gewaer/kanvas-image-resizer

Repository files navigation

kanvas-image-resizer

Image processing service used to rezise images from Amazon S3 bucket dynamically..

Requirements

  • Nodejs v10 or higher
  • pm2
  • nodemon

Setup

Make a copy from .env_default file and rename the file with .env,

  • PORT : this is the port the service will bind
  • AMAZON_S3_BUCKET : this will be the url from your amazon S3 bucket

install node modules

npm install

then you can run the service

npm start   #this will boot the service using pm2

for development

npm run dev  #run with nodemon
npm run inspect  #run with nodemon and debugger enabled

Example

http://localhost:3000/v1/image/rk4eRm.jpg?w=200

Usage

GET -> /image/:image_name ( resize image )

:image_name: amazon_bucket filename

#returns -> Image

query params

Name Type Possible values Required Note
w (width) number any number > 0 false
h (height) number any number > 0 false
fit string cover, contain, fill, inside, outside false
position string top, right top, right, right bottom, bottom, left bottom, left, left top false fit = cover or contain default is center
strategy string entropy, attention false only works with fit = cover
gravity string north, northeast, east, southeast, south, southwest, west, northwest, center, centre false

GET -> /status ( Used to get the service status)

returns -> { "status": "ok" }

Releases

No releases published

Packages

No packages published