node-image-compressor
v1.0.9
Published
NodeJS image compressor
Downloads
65
Maintainers
Readme
npm install compressor --save
⚠️⚠️⚠️⚠️ this module required imageMagic to be installed on your os install imageMagick https://imagemagick.org/script/download.php
##USAGE
let compressor = new Compressor({
input : "my_big_image_file.jpg",
output : "my_compressed_file_path.jpg",
size : "200x200",
quality : 85,
logging : true,
})
compressor.compress((err)=>{
if (!err) console.log("image compressed")
}); //compress image
##API
let compressor = new Compressor({
input : "my_big_image_file.jpg",
output : "my_compressed_file_path.jpg",
size : "200x200",
quality : 85,
logging : true,
})
//Params:filePath: String (default is input image)
//Returns:{is_landscape: boolean, is_square: boolean, width: number, is_portrait: boolean, height: number}
compressor.getImageDimensions(filePath);
//Params:filePath: String
//Returns:boolean
compressor.isPortrait(filePath);
//Params:filePath: String
//Returns:boolean
compressor.isSquare(filePath);
//Params:filePath: String
//Returns:boolean
compressor.isLandscape(filePath)