Skip to content

cantuket/sharp-resizer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sharp Image Resizer API

  • Simple API for resizing remote images
  • Built with Express.js and npm sharp
  • Images processed in momory as Buffers

Demo

http://localhost:3000/demo.html

Modify properties in public/demo.html to experiment with API options.

const resizeProps = {
      width:200,
      height:800,
      fit: "contain",
      cacheLength: 0
    } 
const imgUrl = "https://images.unsplash.com/photo-1546527868-ccb7ee7dfa6a"

Run Locally

Clone the project

  git clone https://github.com/cantuket/sharp-resizer-api

Go to the project directory

  cd sharp-resizer-api

Install dependencies

  npm install

Start the server

  npm run dev

API Reference

Resize a single image

  GET api/img-resize
Parameter Type Description
width integer Set image desired width in pixels
height integer Set image desired height in pixels
fit string How the image should be resized/cropped to fit the target dimension(s), one of cover, contain, fill, inside or outside.
cacheLength integer Define Cache-Control: max-age of image in seconds

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published