1.2.2 • Published 6 years ago
transform-images v1.2.2
transform-images
Super simple function utility that resizes an image and normalizes it's channels using Jimp package
Installation
npm i transform-images
yarn add transform-images
const transform = require('transform-images')
Usage
const source = 'https://images.unsplash.com/photo-1537557132238-b136d7e758ac'
const options = {
width: 300,
height: 180,
output: 'image',
outputFilename: './output.png',
normalized: true,
blur: true,
blurRadius: 5,
quality: 100
}
transform(source, options)
.then(image => console.log('Done!'))
.catch(error => console.error(error))
Return: Promise
Either valid with an JIMP image object or a buffer, or rejected with an error
Source: string
Either a valid URL or a path
Options: Object
An object with desired options
Property | Type | Mandatory | Default | Description |
---|---|---|---|---|
width | number | yes | - | Width of resized image |
height | number | yes | - | Height of resized image |
normalize | boolean | no | true | Apply normalization in brightness & contrast |
output | string | no | image | Output type, image or buffer |
outputFilename | string | yes | - | Output filename when output is image |
blur | boolean | no | false | Set to true if want to blur the image |
blurRadius | number | no | 5 | Spread radius of the blur |
quality | number | no | 100 | Quality of the JPG |