1.2.1 • Published 8 years ago
bl-image-size v1.2.1
image size
npm install bl-image-size --save
Using the sharp module in resizing, a process was created to create multiple images in a single request.
The typical use case for this high speed Node.js module is to convert large images in common formats to smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.
Through a configuration JSON, it is possible to define all the images that will be created.
Examples
import blImageSize from 'bl-image-size';
or
var blImageSize = require('bl-image-size');
var config = {
send: 'test/images/',
original: true,
size: [
{ id: 'thumb', cut: true, w: 100, h: 100 },
{ id: 'img1', cut: false, w: 300, h: 300 },
{ id: 'img2', cut: true, w: 300, h: 300 },
{ id: 'img3', cut: false, w: 720, h: 480 },
{ id: 'img4', cut: false, w: 1024, h: 768 }
]
};
//POMESI
blImageSize(image, config, name, isLocal)
.then((res)=>{
//...
})
.catch((err)=>{
//...
});
##Parameters
- image (required)
- path of the local file or file submitted using the multer
- config (required)
JSON with location where images will be saved and sizes list
var config = { send: <string>, original: <boolean>, size: [ { id: <string>, cut: <boolean>, w: <integer>, h: <integer> }, ... ] };
send - destination folder dasa pictures
- original -
true/false
will the original file be saved? size - array with the data of prefix, cut, height and width of the image.
- id - image prefix
- thumb -> thumb_
- cut -
true/false
the image will be cut to the exact size? otherwise the resizing will use the aspect ratio - w - width
- h - height
- id - image prefix
- nane (no required)
- default:
null
- a string is expected
- if not defined, a new name will be generated
- default:
- isLocal (no required)
- default:
false
- Is the file local?
- default:
License
React is MIT licensed.