Socket
Socket
Sign inDemoInstall

@jimp/plugin-cover

Package Overview
Dependencies
35
Maintainers
2
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.20.2 to 0.21.0--canary.1149.3239903.0

69

dist/index.js

@@ -6,6 +6,4 @@ "use strict";

});
exports["default"] = void 0;
exports.default = void 0;
var _utils = require("@jimp/utils");
/**

@@ -20,42 +18,35 @@ * Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.

*/
var _default = function _default() {
return {
cover: function cover(w, h, alignBits, mode, cb) {
if (typeof w !== "number" || typeof h !== "number") {
return _utils.throwError.call(this, "w and h must be numbers", cb);
}
var _default = () => ({
cover(w, h, alignBits, mode, cb) {
if (typeof w !== "number" || typeof h !== "number") {
return _utils.throwError.call(this, "w and h must be numbers", cb);
}
if (alignBits && typeof alignBits === "function" && typeof cb === "undefined") {
cb = alignBits;
alignBits = null;
mode = null;
} else if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
const hbits = alignBits & (1 << 3) - 1;
const vbits = alignBits >> 3;
if (alignBits && typeof alignBits === "function" && typeof cb === "undefined") {
cb = alignBits;
alignBits = null;
mode = null;
} else if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
// check if more flags than one is in the bit sets
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return _utils.throwError.call(this, "only use one flag per alignment direction", cb);
const alignH = hbits >> 1; // 0, 1, 2
const alignV = vbits >> 1; // 0, 1, 2
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
var hbits = alignBits & (1 << 3) - 1;
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return _utils.throwError.call(this, "only use one flag per alignment direction", cb);
var alignH = hbits >> 1; // 0, 1, 2
var alignV = vbits >> 1; // 0, 1, 2
var f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
this.scale(f, mode);
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
const f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
this.scale(f, mode);
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
};
};
exports["default"] = _default;
return this;
}
});
exports.default = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

@@ -1,10 +0,3 @@

"use strict";
import { isNodePattern, throwError } from "@jimp/utils";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**

@@ -19,41 +12,33 @@ * Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.

*/
var _default = function _default() {
return {
cover: function cover(w, h, alignBits, mode, cb) {
if (typeof w !== "number" || typeof h !== "number") {
return _utils.throwError.call(this, "w and h must be numbers", cb);
}
export default (() => ({
cover(w, h, alignBits, mode, cb) {
if (typeof w !== "number" || typeof h !== "number") {
return throwError.call(this, "w and h must be numbers", cb);
}
if (alignBits && typeof alignBits === "function" && typeof cb === "undefined") {
cb = alignBits;
alignBits = null;
mode = null;
} else if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
const hbits = alignBits & (1 << 3) - 1;
const vbits = alignBits >> 3;
if (alignBits && typeof alignBits === "function" && typeof cb === "undefined") {
cb = alignBits;
alignBits = null;
mode = null;
} else if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
// check if more flags than one is in the bit sets
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return throwError.call(this, "only use one flag per alignment direction", cb);
const alignH = hbits >> 1; // 0, 1, 2
const alignV = vbits >> 1; // 0, 1, 2
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
var hbits = alignBits & (1 << 3) - 1;
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return _utils.throwError.call(this, "only use one flag per alignment direction", cb);
var alignH = hbits >> 1; // 0, 1, 2
var alignV = vbits >> 1; // 0, 1, 2
var f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
this.scale(f, mode);
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
const f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
this.scale(f, mode);
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
};
};
exports["default"] = _default;
return this;
}
}));
//# sourceMappingURL=index.js.map
{
"name": "@jimp/plugin-cover",
"version": "0.20.2",
"version": "0.21.0--canary.1149.3239903.0",
"description": "cover an image.",

@@ -24,4 +24,3 @@ "main": "dist/index.js",

"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "^0.20.2"
"@jimp/utils": "0.21.0--canary.1149.3239903.0"
},

@@ -35,7 +34,7 @@ "peerDependencies": {

"devDependencies": {
"@jimp/custom": "^0.20.2",
"@jimp/plugin-crop": "^0.20.2",
"@jimp/plugin-resize": "^0.20.2",
"@jimp/plugin-scale": "^0.20.2",
"@jimp/test-utils": "^0.20.2"
"@jimp/custom": "0.21.0--canary.1149.3239903.0",
"@jimp/plugin-crop": "0.21.0--canary.1149.3239903.0",
"@jimp/plugin-resize": "0.21.0--canary.1149.3239903.0",
"@jimp/plugin-scale": "0.21.0--canary.1149.3239903.0",
"@jimp/test-utils": "0.21.0--canary.1149.3239903.0"
},

@@ -45,3 +44,3 @@ "publishConfig": {

},
"gitHead": "cebbdb72f889102a8e3c42b25ad3243b16e3a485"
"gitHead": "323990352ce279d67297aed097b37bd8ec66ef51"
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc