Socket
Socket
Sign inDemoInstall

beezlib

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beezlib - npm Package Compare versions

Comparing version 0.9.20 to 0.9.21

51

lib/image/imagemagick.js

@@ -62,2 +62,27 @@ /**

/**
* Get the estimated quality
*
* @name getDefaultQuality
* @memberof imagemagick
* @method
* @param {String} file target file path
* @param {function} callback
* @return {Number} quality
* @example
* beezlib.image.getDefaultQuality('xxx.jpg', function(err, quality) {
* console.log(quality)
* });
*
*/
functions.getDefaultQuality = function (file, callback) {
return this.identify(['-verbose', '-format', '%Q', file], function (err, quality) {
if (err) {
return callback && callback(err);
}
callback && callback(null, parseInt(quality, 10) / 100);
});
};
/**
* Convert file format beez-ratio

@@ -150,2 +175,3 @@ *

* var options = {
* quality: 0.8,
* srcPath: './test/image/logo.png',

@@ -163,9 +189,25 @@ * dstPath: './test/image',

var self = this;
this.getSize(options.srcPath, function(err, res) {
var srcPath = options.srcPath;
new Bucks()
.waterfall([
function (err, res, next) {
self.getSize(srcPath, next);
},
function (err, res, next) {
// do not get the default quality if quality option is set
if (!!options.quality) {
next(null);
}
self.getDefaultQuality(srcPath, next);
}
])
.end(function (err, ress) {
if (err) {
return callback && callback(err, res);
return callback && callback(err);
}
var width = res.width;
var height = res.height;
var width = ress[0].width;
var height = ress[0].height;
var quality = ress[1];

@@ -183,2 +225,3 @@ // parallel load

var resizeOptions = {
quality: options.quality || quality,
srcPath: options.srcPath,

@@ -185,0 +228,0 @@ dstPath: dstPath,

2

package.json
{
"name": "beezlib",
"version": "0.9.20",
"version": "0.9.21",
"description": "The utility library for Node.js using beez projects.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -57,2 +57,11 @@ var fs = require('fs');

it('getDefaultQuality', function (done) {
beezlib.image.imagemagick.getDefaultQuality('test/image/logo.png', function (err, res) {
err && should.fail(err);
res.should.be.ok;
res.should.be.within(0.1, 1.0);
done();
});
});
it('ratioResize', function (done) {

@@ -59,0 +68,0 @@ var baseRatio = 2.0;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc