Coder Social home page Coder Social logo

luke-pomeroy / imageapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 15 KB

A Node.js image API - provide a URL encoded path to an image, and the API will return a resized version of the image 'on-the-fly' based on the image size specified in the URL parameters

JavaScript 100.00%

imageapi's Introduction

imageAPI

A basic Node.js image API - provide a URL encoded path to an image, and the API will return a resized version of the image 'on-the-fly' based on the image size specified in the URL parameters.

server.js

This file uses Express to listen on port 8000 for HTTP/S requests, and also provides basic logging functionality for any errors.

URL Parameters

  • width of desired image in pixels (aspect ratio maintained and filled with white space so image returned is always square)
  • height of desired image in pixels
  • format of desired image (eg png, jpg). 'png' is the default.
  • path to the image to be resized (the path must be URL encoded)

resize.js

This file uses filesystem and sharp to fetch and resize the image. The result is piped via a ReadStream to form the response (a resized image). If the image file cannot be found or read, an error is logged and a 'no image available' image (set via a parameter within this file) is returned instead.

Use

Can be run as a background service via node-linux, node-windows or node-mac.

ToDo

  • Add authentication
  • Add background colour to URL parameters.
  • Add image rotation to URL parameters.

imageapi's People

Contributors

luke-pomeroy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.