@jimp/plugin-crop
Advanced tools
Comparing version 0.22.7 to 0.22.8
@@ -0,1 +1,17 @@ | ||
# v0.22.8 (Thu May 11 2023) | ||
:tada: This release contains work from a new contributor! :tada: | ||
Thank you, Sjoerd ([@sjoerd108](https://github.com/sjoerd108)), for all your work! | ||
#### 🐛 Bug Fix | ||
- Fix autocrop mixing up east and west [#1227](https://github.com/jimp-dev/jimp/pull/1227) ([@sjoerd108](https://github.com/sjoerd108)) | ||
#### Authors: 1 | ||
- Sjoerd ([@sjoerd108](https://github.com/sjoerd108)) | ||
--- | ||
# v0.22.1 (Mon Feb 06 2023) | ||
@@ -2,0 +18,0 @@ |
@@ -162,6 +162,6 @@ "use strict"; | ||
// east side (scan columns from east to west) | ||
// west side (scan columns from west to east) | ||
colorTarget = this.getPixelColor(w, 0); | ||
if (!ignoreSides.east) { | ||
east: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
if (!ignoreSides.west) { | ||
west: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
for (let y = 0 + northPixelsToCrop; y < h; y++) { | ||
@@ -172,3 +172,3 @@ const colorXY = this.getPixelColor(x, y); | ||
// this pixel is too distant from the first one: abort this side scan | ||
break east; | ||
break west; | ||
} | ||
@@ -178,3 +178,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
eastPixelsToCrop++; | ||
westPixelsToCrop++; | ||
} | ||
@@ -201,6 +201,6 @@ } | ||
// west side (scan columns from west to east) | ||
// east side (scan columns from east to west) | ||
colorTarget = this.getPixelColor(w, h); | ||
if (!ignoreSides.west) { | ||
west: for (let x = w - 1; x >= 0 + eastPixelsToCrop + minPixelsPerSide; x--) { | ||
if (!ignoreSides.east) { | ||
east: for (let x = w - 1; x >= 0 + westPixelsToCrop + minPixelsPerSide; x--) { | ||
for (let y = h - 1; y >= 0 + northPixelsToCrop; y--) { | ||
@@ -211,3 +211,3 @@ const colorXY = this.getPixelColor(x, y); | ||
// this pixel is too distant from the first one: abort this side scan | ||
break west; | ||
break east; | ||
} | ||
@@ -217,3 +217,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
westPixelsToCrop++; | ||
eastPixelsToCrop++; | ||
} | ||
@@ -257,3 +257,3 @@ } | ||
// do the real crop | ||
this.crop(eastPixelsToCrop, northPixelsToCrop, widthOfRemainingPixels, heightOfRemainingPixels); | ||
this.crop(westPixelsToCrop, northPixelsToCrop, widthOfRemainingPixels, heightOfRemainingPixels); | ||
} | ||
@@ -260,0 +260,0 @@ if ((0, _utils.isNodePattern)(cb)) { |
@@ -156,6 +156,6 @@ /* eslint-disable no-labels */ | ||
// east side (scan columns from east to west) | ||
// west side (scan columns from west to east) | ||
colorTarget = this.getPixelColor(w, 0); | ||
if (!ignoreSides.east) { | ||
east: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
if (!ignoreSides.west) { | ||
west: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
for (let y = 0 + northPixelsToCrop; y < h; y++) { | ||
@@ -166,3 +166,3 @@ const colorXY = this.getPixelColor(x, y); | ||
// this pixel is too distant from the first one: abort this side scan | ||
break east; | ||
break west; | ||
} | ||
@@ -172,3 +172,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
eastPixelsToCrop++; | ||
westPixelsToCrop++; | ||
} | ||
@@ -195,6 +195,6 @@ } | ||
// west side (scan columns from west to east) | ||
// east side (scan columns from east to west) | ||
colorTarget = this.getPixelColor(w, h); | ||
if (!ignoreSides.west) { | ||
west: for (let x = w - 1; x >= 0 + eastPixelsToCrop + minPixelsPerSide; x--) { | ||
if (!ignoreSides.east) { | ||
east: for (let x = w - 1; x >= 0 + westPixelsToCrop + minPixelsPerSide; x--) { | ||
for (let y = h - 1; y >= 0 + northPixelsToCrop; y--) { | ||
@@ -205,3 +205,3 @@ const colorXY = this.getPixelColor(x, y); | ||
// this pixel is too distant from the first one: abort this side scan | ||
break west; | ||
break east; | ||
} | ||
@@ -211,3 +211,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
westPixelsToCrop++; | ||
eastPixelsToCrop++; | ||
} | ||
@@ -251,3 +251,3 @@ } | ||
// do the real crop | ||
this.crop(eastPixelsToCrop, northPixelsToCrop, widthOfRemainingPixels, heightOfRemainingPixels); | ||
this.crop(westPixelsToCrop, northPixelsToCrop, widthOfRemainingPixels, heightOfRemainingPixels); | ||
} | ||
@@ -254,0 +254,0 @@ if (isNodePattern(cb)) { |
{ | ||
"name": "@jimp/plugin-crop", | ||
"version": "0.22.7", | ||
"version": "0.22.8", | ||
"description": "crop an image.", | ||
@@ -24,7 +24,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@jimp/utils": "^0.22.7" | ||
"@jimp/utils": "^0.22.8" | ||
}, | ||
"devDependencies": { | ||
"@jimp/custom": "^0.22.7", | ||
"@jimp/test-utils": "^0.22.7" | ||
"@jimp/custom": "^0.22.8", | ||
"@jimp/test-utils": "^0.22.8" | ||
}, | ||
@@ -37,3 +37,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "965a14e14d6e2acf81ddf78c30b4c85d921ea7db" | ||
"gitHead": "a5b93f822d63ffc0d20cb67adf03b1322e6a8f1b" | ||
} |
@@ -163,6 +163,6 @@ /* eslint-disable no-labels */ | ||
// east side (scan columns from east to west) | ||
// west side (scan columns from west to east) | ||
colorTarget = this.getPixelColor(w, 0); | ||
if (!ignoreSides.east) { | ||
east: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
if (!ignoreSides.west) { | ||
west: for (let x = 0; x < w - minPixelsPerSide; x++) { | ||
for (let y = 0 + northPixelsToCrop; y < h; y++) { | ||
@@ -174,3 +174,3 @@ const colorXY = this.getPixelColor(x, y); | ||
// this pixel is too distant from the first one: abort this side scan | ||
break east; | ||
break west; | ||
} | ||
@@ -180,3 +180,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
eastPixelsToCrop++; | ||
westPixelsToCrop++; | ||
} | ||
@@ -209,8 +209,8 @@ } | ||
// west side (scan columns from west to east) | ||
// east side (scan columns from east to west) | ||
colorTarget = this.getPixelColor(w, h); | ||
if (!ignoreSides.west) { | ||
west: for ( | ||
if (!ignoreSides.east) { | ||
east: for ( | ||
let x = w - 1; | ||
x >= 0 + eastPixelsToCrop + minPixelsPerSide; | ||
x >= 0 + westPixelsToCrop + minPixelsPerSide; | ||
x-- | ||
@@ -224,3 +224,3 @@ ) { | ||
// this pixel is too distant from the first one: abort this side scan | ||
break west; | ||
break east; | ||
} | ||
@@ -230,3 +230,3 @@ } | ||
// this column contains all pixels with the same color: increment this side pixels to crop | ||
westPixelsToCrop++; | ||
eastPixelsToCrop++; | ||
} | ||
@@ -284,3 +284,3 @@ } | ||
this.crop( | ||
eastPixelsToCrop, | ||
westPixelsToCrop, | ||
northPixelsToCrop, | ||
@@ -287,0 +287,0 @@ widthOfRemainingPixels, |
@@ -378,7 +378,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; | ||
mkJGD( | ||
" ◆◆ ", | ||
" ◆▦▦◆ ", | ||
"◆▦▦▦▦◆ ", | ||
" ◆▦▦◆ ", | ||
" ◆◆ ", | ||
" ◆◆ ", | ||
" ◆▦▦◆ ", | ||
" ◆▦▦▦▦◆", | ||
" ◆▦▦◆ ", | ||
" ◆◆ ", | ||
" " | ||
@@ -406,5 +406,5 @@ ) | ||
.getJGDSync(), | ||
mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") | ||
mkJGD(" ◆◆ ", " ◆▦▦◆ ", "◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") | ||
); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89091
Updated@jimp/utils@^0.22.8