Transforms images in a directory to perfect squares.
npm i squarifier
or yarn add squarifier
If you want to squarify all of the images in a given directory with a max size of 1200 pixels and fill the margin with a black background color, you can do the following:
let squarifier = require('squarifier');
squarifier('path/to/img/folder', 1200, 0x000000FF)
.catch(err => {
console.log(err);
}).then((counter) => {
console.log(`Done. Changed ${counter} files.`);
});
node path/to/squarifier/index.js -d path/to/img/folder -s 1200 -c 0x000000FF
For more examples, see examples.
-d, --directory [path]
target directory (required)
-s --size [integer]
output canvas size (default is 1000)
-c --color [0xrrggbbaa]
background color (default is 0xffffffff)
-h, --help
output usage information
- bmp
- gif
- jpeg
- png
- tiff
Other formats will be ignored.
- Node version 7.6.0 and above
- Christoffer Ekblom