JSPM

generic-image-server

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q34842F
  • License MIT

Generic image server. You can resize or cut images, with a specific resolution passed in the url

Package Exports

  • generic-image-server

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (generic-image-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Generic Image Server with Node.js

Description

Image server implemented with Node.js. The server provides an image and resize it maintaining its aspect ratio. You need to specify a image resolution in order to resize it.

By default, if the original image resolutions is smaller than the requested one, it cannot be extended. To force the extend, you must specify in the url a parameter force=true.

You can also crop the image with the resolution requested in the url. To do that, you need to specify a fit=true at url parameters.

Prerequisites

Configuration

You can customize the service through command line arguments:

Usage: images.js [options] pathToImageFolder

Image service
  --port, -p  Port number the service will listen to  [number] [default: 3002]
  --yMax, -y  Maximum height  [number] [default: 1200]
  --xMax, -x  Maximum width  [number] [default: 1200]

Redis cache
  --redisHost, -h  Redis server hostname  [string] [default: "localhost"]
  --redisPort, -o  Redis server port  [number] [default: 6379]
  --redisTTL, -t   Redis cache TTL  [number] [default: 3600]

Opciones:
  --help  Show help  [boolean]

Usage

With your Redis Server running:

    $ npm install generic-image-server && cd node_modules/generic-image-server
    $ npm install
    $ node images.js /path/to/image/repository

There's also a systemd service file example included. You may want to edit it and change ExecStart and/or User.

Examples

  • localhost:3003/400/400/images/image2.jpg
  • localhost:3003/1200/1200/images/image2.jpg?fit=true
  • localhost:3003/400/400/images/image2.jpg?force=true
  • localhost:3003/400/400/images/image2.jpg?fit=true&force=true