Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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.1 to 0.6.2

18

dist/index.js

@@ -153,3 +153,2 @@ "use strict";

// this pixel is too distant from the first one: abort this side scan
northPixelsToCrop -= leaveBorder;
break north;

@@ -174,3 +173,2 @@ }

// this pixel is too distant from the first one: abort this side scan
eastPixelsToCrop -= leaveBorder;
break east;

@@ -195,3 +193,2 @@ }

// this pixel is too distant from the first one: abort this side scan
southPixelsToCrop -= leaveBorder;
break south;

@@ -216,3 +213,2 @@ }

// this pixel is too distant from the first one: abort this side scan
westPixelsToCrop -= leaveBorder;
break west;

@@ -227,4 +223,9 @@ }

var doCrop = false;
var doCrop = false; // apply leaveBorder
westPixelsToCrop = westPixelsToCrop - leaveBorder;
eastPixelsToCrop = eastPixelsToCrop - leaveBorder;
northPixelsToCrop = northPixelsToCrop - leaveBorder;
southPixelsToCrop = southPixelsToCrop - leaveBorder;
if (cropSymmetric) {

@@ -241,4 +242,9 @@ var horizontal = Math.min(eastPixelsToCrop, westPixelsToCrop);

var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop);
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;
if (cropOnlyFrames) {

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

@@ -140,3 +140,2 @@ 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); }

// this pixel is too distant from the first one: abort this side scan
northPixelsToCrop -= leaveBorder;
break north;

@@ -161,3 +160,2 @@ }

// this pixel is too distant from the first one: abort this side scan
eastPixelsToCrop -= leaveBorder;
break east;

@@ -182,3 +180,2 @@ }

// this pixel is too distant from the first one: abort this side scan
southPixelsToCrop -= leaveBorder;
break south;

@@ -203,3 +200,2 @@ }

// this pixel is too distant from the first one: abort this side scan
westPixelsToCrop -= leaveBorder;
break west;

@@ -214,4 +210,9 @@ }

var doCrop = false;
var doCrop = false; // apply leaveBorder
westPixelsToCrop = westPixelsToCrop - leaveBorder;
eastPixelsToCrop = eastPixelsToCrop - leaveBorder;
northPixelsToCrop = northPixelsToCrop - leaveBorder;
southPixelsToCrop = southPixelsToCrop - leaveBorder;
if (cropSymmetric) {

@@ -228,4 +229,9 @@ var horizontal = Math.min(eastPixelsToCrop, westPixelsToCrop);

var widthOfRemainingPixels = w - (westPixelsToCrop + eastPixelsToCrop);
var heightOfRemainingPixels = h - (southPixelsToCrop + northPixelsToCrop);
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;
if (cropOnlyFrames) {

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

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

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

"devDependencies": {
"@jimp/custom": "^0.6.0",
"@jimp/test-utils": "^0.6.0"
"@jimp/custom": "^0.6.2",
"@jimp/test-utils": "^0.6.2"
},

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

},
"gitHead": "495fa8852fde16bada8bbdf6433ab2f197a4d35e"
"gitHead": "6d52efed23e47bb6f7c27bb2ae9e119d05db4dd3"
}

@@ -143,3 +143,2 @@ /* eslint-disable no-labels */

// this pixel is too distant from the first one: abort this side scan
northPixelsToCrop -= leaveBorder;
break north;

@@ -161,3 +160,2 @@ }

// this pixel is too distant from the first one: abort this side scan
eastPixelsToCrop -= leaveBorder;
break east;

@@ -183,3 +181,2 @@ }

// this pixel is too distant from the first one: abort this side scan
southPixelsToCrop -= leaveBorder;
break south;

@@ -205,3 +202,2 @@ }

// this pixel is too distant from the first one: abort this side scan
westPixelsToCrop -= leaveBorder;
break west;

@@ -217,2 +213,8 @@ }

// apply leaveBorder
westPixelsToCrop = westPixelsToCrop - leaveBorder;
eastPixelsToCrop = eastPixelsToCrop - leaveBorder;
northPixelsToCrop = northPixelsToCrop - leaveBorder;
southPixelsToCrop = southPixelsToCrop - leaveBorder;
if (cropSymmetric) {

@@ -233,2 +235,8 @@ const horizontal = Math.min(eastPixelsToCrop, westPixelsToCrop);

// 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) {

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

@@ -286,2 +286,36 @@ import { Jimp, mkJGD } from '@jimp/test-utils';

});
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