oversized-images
v0.0.3
Published
checks image sizes and creates a preview version
Downloads
2
Readme
Oversized
##creates a preview from oversized images
When you are working with professional camera equipment it is common that you encounter oversized picture resolutions that will cause rendering problems in a web context.
To prevent this, the Oversized package allows the dynamic creation of preview images. In order to make use of it, you have to browserify your project.
npm install oversized-images
To require it, call:
var oversized = require("oversized-images");
Then you create an oversized object:
var reducer = new oversized({
max: 1.4,
max_width: 1920,
max_height: 1080,
suffix: '_prvw'
});
- max: affects all the pictures that have a size greater than max [in MB]
- max-width: the maximal width of your preview
- max-height: the maximal height of your preview
- suffix: allows you to define the preview suffix
- callback: callback function, receives the array of files that suffices the preview condition
To invoke the reduction process, call
reducer.check([files]);
The parameter files takes a directory, as single files or an array of files. If you choose a directory, the library uses a recursive directory search. Therefore, you can scan and manipulate all the embedded subfolders. Since the library uses Q promises, all the calls are chained. By using a callback you can use it asynchronously.
So your call might look like this:
function done(result) {
console.log("processed " + result);
};
var test = new Oversized({
max: 1.4,
max_width: 1920,
max_height: 1080,
callback: done,
});
var a = test.check(["file1.jpg", "file2.jpg", "file3.jpg"]);
The callback gets an array of files that matches the preview conditions.