Socket
Socket
Sign inDemoInstall

@jimp/plugin-crop

Package Overview
Dependencies
Maintainers
2
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/plugin-crop - npm Package Compare versions

Comparing version 0.6.6 to 0.6.7

10

dist/index.js

@@ -233,13 +233,13 @@ "use strict";

southPixelsToCrop = vertical;
} // safety checks
} // make sure that crops are >= 0
var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop); // make sure that crops are > 0
westPixelsToCrop = westPixelsToCrop >= 0 ? westPixelsToCrop : 0;
eastPixelsToCrop = eastPixelsToCrop >= 0 ? eastPixelsToCrop : 0;
northPixelsToCrop = northPixelsToCrop >= 0 ? northPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0; // safety checks
var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop);
if (cropOnlyFrames) {

@@ -246,0 +246,0 @@ // crop image if all sides should be cropped

@@ -220,13 +220,13 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

southPixelsToCrop = vertical;
} // safety checks
} // make sure that crops are >= 0
var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop); // make sure that crops are > 0
westPixelsToCrop = westPixelsToCrop >= 0 ? westPixelsToCrop : 0;
eastPixelsToCrop = eastPixelsToCrop >= 0 ? eastPixelsToCrop : 0;
northPixelsToCrop = northPixelsToCrop >= 0 ? northPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0; // safety checks
var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop);
if (cropOnlyFrames) {

@@ -233,0 +233,0 @@ // crop image if all sides should be cropped

{
"name": "@jimp/plugin-crop",
"version": "0.6.6",
"version": "0.6.7",
"description": "crop an image.",

@@ -22,8 +22,8 @@ "main": "dist/index.js",

"dependencies": {
"@jimp/utils": "^0.6.6",
"@jimp/utils": "^0.6.7",
"core-js": "^2.5.7"
},
"devDependencies": {
"@jimp/custom": "^0.6.6",
"@jimp/test-utils": "^0.6.6"
"@jimp/custom": "^0.6.7",
"@jimp/test-utils": "^0.6.7"
},

@@ -36,3 +36,3 @@ "peerDependencies": {

},
"gitHead": "72f4171b9de0bc27cdd2a014c4da726151b8da0e"
"gitHead": "88b63e68275c60fe0dce3056657b845bb169065c"
}

@@ -224,2 +224,8 @@ /* eslint-disable no-labels */

// make sure that crops are >= 0
westPixelsToCrop = westPixelsToCrop >= 0 ? westPixelsToCrop : 0;
eastPixelsToCrop = eastPixelsToCrop >= 0 ? eastPixelsToCrop : 0;
northPixelsToCrop = northPixelsToCrop >= 0 ? northPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0;
// safety checks

@@ -231,8 +237,2 @@ const widthOfRemainingPixels =

// make sure that crops are > 0
westPixelsToCrop = westPixelsToCrop >= 0 ? westPixelsToCrop : 0;
eastPixelsToCrop = eastPixelsToCrop >= 0 ? eastPixelsToCrop : 0;
northPixelsToCrop = northPixelsToCrop >= 0 ? northPixelsToCrop : 0;
southPixelsToCrop = southPixelsToCrop >= 0 ? southPixelsToCrop : 0;
if (cropOnlyFrames) {

@@ -239,0 +239,0 @@ // crop image if all sides should be cropped

@@ -253,3 +253,3 @@ import { Jimp, mkJGD } from '@jimp/test-utils';

it('image without frame and with with some border left', async () => {
it('image without frame and with some border left', async () => {
const imgSrc = await Jimp.read(

@@ -287,2 +287,72 @@ mkJGD(

});
it('image not cropped given an out of bounds "leaveBorder" value ', async () => {
const imgSrc = await Jimp.read(
mkJGD(
'323232323232',
'232323232323',
'32 ◆◆ 32',
'23 ◆▦▦◆ 23',
'32 ◆▦▦▦▦◆ 32',
'23 ◆▦▦◆ 23',
'32 ◆◆ 32',
'232323232323',
'323232323232'
)
);
imgSrc
.autocrop({
tolerance: 0.005,
leaveBorder: 100
})
.getJGDSync()
.should.be.sameJGD(
mkJGD(
'323232323232',
'232323232323',
'32 ◆◆ 32',
'23 ◆▦▦◆ 23',
'32 ◆▦▦▦▦◆ 32',
'23 ◆▦▦◆ 23',
'32 ◆◆ 32',
'232323232323',
'323232323232'
)
);
});
it('image with top and bottom frame and leaveBorder', async () => {
const imgSrc = await Jimp.read(
mkJGD(
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥',
' ◆◆ ',
' ◆▦▦◆ ',
' ◆▦▦▦▦◆ ',
' ◆▦▦◆ ',
' ◆◆ ',
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥'
)
);
imgSrc
.autocrop({ cropSymmetric: true, cropOnlyFrames: false, leaveBorder: 2 })
.getJGDSync()
.should.be.sameJGD(
mkJGD(
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥',
' ◆◆ ',
' ◆▦▦◆ ',
' ◆▦▦▦▦◆ ',
' ◆▦▦◆ ',
' ◆◆ ',
'▥▥▥▥▥▥▥▥',
'▥▥▥▥▥▥▥▥'
)
);
});
});

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