Skip to content

domus71/imagesharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageSharp

Status GitHub Issues GitHub Pull Requests License


A simple web interface to generate image.

📝 Table of Contents

🧐 About

A simple web interface to generate image using Sharp for Node.js.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installing

First clone the project to your development enviroment.

git clone https://github.com/domus71/imagesharp.git

You have to install Sharp ang Express framework usign npm.

npm install

🎈 Usage

The default port is 3001. You can change port from config.json

node index.js

On your browser to get information (metadata) as json object:

http://localhost:3001/getinfo?source=<fullpath of source image file>

On your browser to generate new image:

http://localhost:3001/generate?source=<fullpath of source image file>&dest=<fullpath of generated image file>&width=<pixels>&height=<pixels>&quality=<from 1 to 100>&lossless=<0/1/true/on>&progressive=<0/1/true/on>&wimage=<watermark file>&wposition=<watermark position ex.southwest>&pos=<image position for cropping, see rposition array>

The source and the destanation image paths must be url encoded. If width and height are 0, then image keeps the original size. The properties quality, lossless and progressive are optional. Default quality is 80%. Also, I have disabled the Sharp cache to get new file everytime. You can comment the line 9 to speed up things and change Sharp caching options. The generated image is centered and cropped/clipped in given dimensions to fit by default. You can change that using image position pos=0..8 (see rposition array 0:"left top", 1:"top" 2:"right top", ... 7: "bottom", 8: "right bottom")

🚀 Deployment

You can change the port and/or convert it to Windows service using NSSM. I use it as an internal service to convert big PNG files to WebP format.

⛏️ Built Using

  • Express - Server Framework
  • Sharp - High performance Node.js image processing
  • NodeJs - Server Environment

✍️ Authors

🎉 Acknowledgements

  • Hate old Windows DLLs

About

Sharp image processing and Express service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published