1.1.0 • Published 4 years ago

portal-image v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Portal image

A REST service providing a set of image editing capabilities.

Endpoints

POST /api/transform

REST service with which you can 1) store an image 2) generate and store one or multiple transformations of an image 3) perform and store additional transformation on an earlier stored image

Form data:

field nametyperequiredmeaning
imagefileonly if imageName is not providedimage you want to (transform and) store
imageNamefileonly if image is not providedimage you want to (transform and) retrieve
transformationDefinitionsjsonnoJSON object containing a description of the transformations you would like to apply to the image. See transformations.

Returns: An object containing paths to the original version and all requested transformed images.

[
    {
        "label": "original",
        "name": "7a9070e4016272e445fe11e0a73c748d4b4bad2039fbf350870a88a8b9c940d5.png"
    },
    {
        "label": "medium-grayscale",
        "name": "208d634ff4dec3952b5e9d4ae2fddf29cb8363d96add6bb7f3ac9c2bda0beaa3.png"
    },
    {
        "label": "medium",
        "name": "494e5d5bc7a20de5878bca08c84555e384959bef0edb486c69c3f5ec2f95e5a6.png"
    }
]

Exceptions:

HTTP codeoccurs whenpreconditions
404if image with given name does not existonly applicable when imageName is provided

GET /api/retrieve/{imageName}

Returns: Returns earlier stored image.

Exceptions:

HTTP codeoccurs whenpreconditions
404if image with given name does not exist

Transformations

Transformations needs to be provided as a double array.

Example:

[
  {
    "label": "medium-greyscale",
    "transformations": [ 
      { "name": "resize", "width": 500, "height": 400, "crop": true }, 
      { "name": "greyscale"}
    ]
  }, {
    "label": "medium-color",
    "transformations": [ 
      { "name": "resize", "width": 500, "height": 400, "crop": true }
    ]
  }
]

results in

  • the original image
  • a resized image in greyscale
  • a resized image (in color)
[
    {
        "label": "original",
        "name": "7a9070e4016272e445fe11e0a73c748d4b4bad2039fbf350870a88a8b9c940d5.png"
    },
    {
        "label": "medium-greyscale",
        "name": "208d634ff4dec3952b5e9d4ae2fddf29cb8363d96add6bb7f3ac9c2bda0beaa3.png"
    },
    {
        "label": "medium-color",
        "name": "494e5d5bc7a20de5878bca08c84555e384959bef0edb486c69c3f5ec2f95e5a6.png"
    }
]

Resize

Resizes the image to a desired size.

field nametyperequiredmeaning
widthnumberyesWidth in pixels.
heightnumbernoHeight in pixels. If no height is given, the aspect ratio of the image is respected.
cropbooleannoIf both width and height are given, and the aspect ratio of the desired image does not match the aspect ratio of the source image, is it allowed to crop the image so that the aspect ratio can be respected?

Greyscale

Turns an image into greyscale.

No options available.

Environment variables

NameExample valueDescriptionRequired?
EUREKA_HOSTportal-eurekaHostname of the Eureka serveroptional
EUREKA_PORT8761Port that the Eureka server usesoptional
EUREKA_SERVICE_PATH/eureka/apps/Service path of Eurekaoptional
HOSTNAMElocalhostHostname of the server on which this application can be reached. Used by Eurekaoptional
PORT3000Port that the Node server should useoptional
IP_ADDRESS127.0.0.1IP address on which this application can be reached. Used by Eurekaoptional

Architecture

Architecture

Development

What do I need to do to install the app locally?

  1. Install Node 13+
  2. npm install

How to start the app locally?

node app/app.js

How to build the Docker image?

docker build . --tag=stainii/portal-image:[version]

How to publish?

docker login
docker push stainii/portal-image:[version]

Release

On the dev branch, in app folder: 1. Set version in package.json 1. git add package.json 1. git commit -m "release [version] 1. npm login
1. npm publish --access=public 1. cd .. 1. docker build . --tag=stainii/portal-image:[version]
1. docker push stainii/portal-image:[version]
1. git tag [version] 1. git push --tags 1. merge with the master branch