Initial commit

This commit is contained in:
robert committed 2025-05-30 18:13:30 +08:00
commit e49726988c
5445 files changed
+1089914

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../src",
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../**/*.test.ts",
"../src/**/*.mts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../**/*.test.ts",
"../src/package.json"
],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
}
+5
View File
@@ -0,0 +1,5 @@

> @jimp/plugin-blur@1.5.0 build /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
> tshy
+5
View File
@@ -0,0 +1,5 @@

> @jimp/plugin-blur@1.1.2 lint /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
> eslint .
+14
View File
@@ -0,0 +1,14 @@
> @jimp/plugin-blur@1.1.1 test:browser /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
> vitest --config vitest.config.browser.mjs "--watch=false" "--u"
 RUN  v1.4.0 /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
 Browser runner started at http://localhost:5175/
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
exclude: **/.tshy-build, **/.tshy, **/*.node.test.ts, **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
watch exclude: **/node_modules/**, **/dist/**

No test files found, exiting with code 1
 ELIFECYCLE  Command failed with exit code 1.
+24
View File
@@ -0,0 +1,24 @@

> @jimp/plugin-blur@1.1.2 test /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
> vitest "--watch=false"
 RUN  v2.0.5 /Users/andrewlisowski/Documents/jimp/plugins/plugin-blur
[?25l · src/index.node.test.ts (1)
· hasAlpha (1)
· image with alpha
[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ src/index.node.test.ts (1) 2656ms
✓ hasAlpha (1) 2656ms
✓ image with alpha 2656ms
 ✓ src/index.node.test.ts (1) 2656ms
✓ hasAlpha (1) 2656ms
✓ image with alpha 2656ms
 Test Files  1 passed (1)
 Tests  1 passed (1)
 Start at  01:33:52
 Duration  4.88s (transform 1.16s, setup 0ms, collect 1.40s, tests 2.66s, environment 0ms, prepare 511ms)
[?25h[?25h
+64
View File
@@ -0,0 +1,64 @@
# v1.1.3 (Mon Sep 02 2024)
#### 🐛 Bug Fix
- Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v1.1.2 (Mon Sep 02 2024)
#### 🐛 Bug Fix
- Fix blur on transparent images [#1315](https://github.com/jimp-dev/jimp/pull/1315) ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v1.1.0 (Sun Sep 01 2024)
#### ⚠️ Pushed to `main`
- upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
- update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v1.0.3 (Sat Aug 31 2024)
#### 🐛 Bug Fix
- Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### ⚠️ Pushed to `main`
- add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v1.0.2 (Sat Aug 31 2024)
#### ⚠️ Pushed to `main`
- set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie))
- fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie))
- add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Oliver Moran
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+11
View File
@@ -0,0 +1,11 @@
<div align="center">
<img width="200" height="200"
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
<h1>@jimp/plugin-blur</h1>
<p>Blur an image.</p>
</div>
A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
- [blur](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blur)
- [gaussian](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#gaussian)
+3
View File
@@ -0,0 +1,3 @@
export declare const mulTable: number[];
export declare const shgTable: number[];
//# sourceMappingURL=blur-tables.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"blur-tables.d.ts","sourceRoot":"","sources":["../../src/blur-tables.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAiBpB,CAAC;AAEF,eAAO,MAAM,QAAQ,UAepB,CAAC"}
+38
View File
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shgTable = exports.mulTable = void 0;
exports.mulTable = [
1, 57, 41, 21, 203, 34, 97, 73, 227, 91, 149, 62, 105, 45, 39, 137, 241, 107,
3, 173, 39, 71, 65, 238, 219, 101, 187, 87, 81, 151, 141, 133, 249, 117, 221,
209, 197, 187, 177, 169, 5, 153, 73, 139, 133, 127, 243, 233, 223, 107, 103,
99, 191, 23, 177, 171, 165, 159, 77, 149, 9, 139, 135, 131, 253, 245, 119,
231, 224, 109, 211, 103, 25, 195, 189, 23, 45, 175, 171, 83, 81, 79, 155, 151,
147, 9, 141, 137, 67, 131, 129, 251, 123, 30, 235, 115, 113, 221, 217, 53, 13,
51, 50, 49, 193, 189, 185, 91, 179, 175, 43, 169, 83, 163, 5, 79, 155, 19, 75,
147, 145, 143, 35, 69, 17, 67, 33, 65, 255, 251, 247, 243, 239, 59, 29, 229,
113, 111, 219, 27, 213, 105, 207, 51, 201, 199, 49, 193, 191, 47, 93, 183,
181, 179, 11, 87, 43, 85, 167, 165, 163, 161, 159, 157, 155, 77, 19, 75, 37,
73, 145, 143, 141, 35, 138, 137, 135, 67, 33, 131, 129, 255, 63, 250, 247, 61,
121, 239, 237, 117, 29, 229, 227, 225, 111, 55, 109, 216, 213, 211, 209, 207,
205, 203, 201, 199, 197, 195, 193, 48, 190, 47, 93, 185, 183, 181, 179, 178,
176, 175, 173, 171, 85, 21, 167, 165, 41, 163, 161, 5, 79, 157, 78, 154, 153,
19, 75, 149, 74, 147, 73, 144, 143, 71, 141, 140, 139, 137, 17, 135, 134, 133,
66, 131, 65, 129, 1,
];
exports.shgTable = [
0, 9, 10, 10, 14, 12, 14, 14, 16, 15, 16, 15, 16, 15, 15, 17, 18, 17, 12, 18,
16, 17, 17, 19, 19, 18, 19, 18, 18, 19, 19, 19, 20, 19, 20, 20, 20, 20, 20,
20, 15, 20, 19, 20, 20, 20, 21, 21, 21, 20, 20, 20, 21, 18, 21, 21, 21, 21,
20, 21, 17, 21, 21, 21, 22, 22, 21, 22, 22, 21, 22, 21, 19, 22, 22, 19, 20,
22, 22, 21, 21, 21, 22, 22, 22, 18, 22, 22, 21, 22, 22, 23, 22, 20, 23, 22,
22, 23, 23, 21, 19, 21, 21, 21, 23, 23, 23, 22, 23, 23, 21, 23, 22, 23, 18,
22, 23, 20, 22, 23, 23, 23, 21, 22, 20, 22, 21, 22, 24, 24, 24, 24, 24, 22,
21, 24, 23, 23, 24, 21, 24, 23, 24, 22, 24, 24, 22, 24, 24, 22, 23, 24, 24,
24, 20, 23, 22, 23, 24, 24, 24, 24, 24, 24, 24, 23, 21, 23, 22, 23, 24, 24,
24, 22, 24, 24, 24, 23, 22, 24, 24, 25, 23, 25, 25, 23, 24, 25, 25, 24, 22,
25, 25, 25, 24, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23,
25, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 22, 25, 25, 23, 25, 25,
20, 24, 25, 24, 25, 25, 22, 24, 25, 24, 25, 24, 25, 25, 24, 25, 25, 25, 25,
22, 25, 25, 25, 24, 25, 24, 25, 18,
];
//# sourceMappingURL=blur-tables.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"blur-tables.js","sourceRoot":"","sources":["../../src/blur-tables.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACtB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5E,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5E,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC3E,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,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EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1E,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EALine truncated
+30
View File
@@ -0,0 +1,30 @@
import { JimpClass } from "@jimp/types";
export declare const methods: {
/**
* A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.blur(5);
* ```
*/
blur<I extends JimpClass>(image: I, r: number): I;
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.gaussian(15);
* ```
*/
gaussian<I extends JimpClass>(image: I, r: number): I;
};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA+BxC,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;OAWG;SACE,CAAC,SAAS,SAAS,SAAS,CAAC,KAAK,MAAM;IAgI7C;;;;;;;;;;;OAWG;aACM,CAAC,SAAS,SAAS,SAAS,CAAC,KAAK,MAAM;CAiElD,CAAC"}
+211
View File
@@ -0,0 +1,211 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.methods = void 0;
const blur_tables_js_1 = require("./blur-tables.js");
const utils_1 = require("@jimp/utils");
/*
Superfast Blur (0.5)
http://www.quasimondo.com/BoxBlurForCanvas/FastBlur.js
Copyright (c) 2011 Mario Klingemann
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
exports.methods = {
/**
* A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.blur(5);
* ```
*/
blur(image, r) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
let rsum;
let gsum;
let bsum;
let asum;
let x;
let y;
let i;
let p;
let p1;
let p2;
let yp;
let yi;
let yw;
const wm = image.bitmap.width - 1;
const hm = image.bitmap.height - 1;
// const wh = image.bitmap.width * image.bitmap.height;
const rad1 = r + 1;
const mulSum = blur_tables_js_1.mulTable[r];
const shgSum = blur_tables_js_1.shgTable[r];
const red = [];
const green = [];
const blue = [];
const alpha = [];
const vmin = [];
const vmax = [];
let iterations = 2;
while (iterations-- > 0) {
yi = 0;
yw = 0;
for (y = 0; y < image.bitmap.height; y++) {
rsum = image.bitmap.data[yw] * rad1;
gsum = image.bitmap.data[yw + 1] * rad1;
bsum = image.bitmap.data[yw + 2] * rad1;
asum = image.bitmap.data[yw + 3] * rad1;
for (i = 1; i <= r; i++) {
p = yw + ((i > wm ? wm : i) << 2);
rsum += image.bitmap.data[p++];
gsum += image.bitmap.data[p++];
bsum += image.bitmap.data[p++];
asum += image.bitmap.data[p];
}
for (x = 0; x < image.bitmap.width; x++) {
red[yi] = rsum;
green[yi] = gsum;
blue[yi] = bsum;
alpha[yi] = asum;
if (y === 0) {
vmin[x] = ((p = x + rad1) < wm ? p : wm) << 2;
vmax[x] = (p = x - r) > 0 ? p << 2 : 0;
}
p1 = yw + vmin[x];
p2 = yw + vmax[x];
rsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
gsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
bsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
asum += image.bitmap.data[p1] - image.bitmap.data[p2++];
yi++;
}
yw += image.bitmap.width << 2;
}
for (x = 0; x < image.bitmap.width; x++) {
yp = x;
rsum = red[yp] * rad1;
gsum = green[yp] * rad1;
bsum = blue[yp] * rad1;
asum = alpha[yp] * rad1;
for (i = 1; i <= r; i++) {
yp += i > hm ? 0 : image.bitmap.width;
rsum += red[yp];
gsum += green[yp];
bsum += blue[yp];
asum += alpha[yp];
}
yi = x << 2;
for (y = 0; y < image.bitmap.height; y++) {
image.bitmap.data[yi] = (0, utils_1.limit255)((rsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 1] = (0, utils_1.limit255)((gsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 2] = (0, utils_1.limit255)((bsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 3] = (0, utils_1.limit255)((asum * mulSum) >>> shgSum);
if (x === 0) {
vmin[y] = ((p = y + rad1) < hm ? p : hm) * image.bitmap.width;
vmax[y] = (p = y - r) > 0 ? p * image.bitmap.width : 0;
}
p1 = x + vmin[y];
p2 = x + vmax[y];
rsum += red[p1] - red[p2];
gsum += green[p1] - green[p2];
bsum += blue[p1] - blue[p2];
asum += alpha[p1] - alpha[p2];
yi += image.bitmap.width << 2;
}
}
}
return image;
},
// http://blog.ivank.net/fastest-gaussian-blur.html
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.gaussian(15);
* ```
*/
gaussian(image, r) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
const rs = Math.ceil(r * 2.57); // significant radius
const range = rs * 2 + 1;
const rr2 = r * r * 2;
const rr2pi = rr2 * Math.PI;
const weights = [];
for (let y = 0; y < range; y++) {
const weightsRow = [];
for (let x = 0; x < range; x++) {
const dsq = (x - rs) ** 2 + (y - rs) ** 2;
weightsRow[x] = Math.exp(-dsq / rr2) / rr2pi;
}
weights.push(weightsRow);
}
for (let y = 0; y < image.bitmap.height; y++) {
for (let x = 0; x < image.bitmap.width; x++) {
let red = 0;
let green = 0;
let blue = 0;
let alpha = 0;
let wsum = 0;
for (let iy = 0; iy < range; iy++) {
for (let ix = 0; ix < range; ix++) {
const x1 = Math.min(image.bitmap.width - 1, Math.max(0, ix + x - rs));
const y1 = Math.min(image.bitmap.height - 1, Math.max(0, iy + y - rs));
const weight = weights[iy][ix];
const idx = (y1 * image.bitmap.width + x1) << 2;
red += image.bitmap.data[idx] * weight;
green += image.bitmap.data[idx + 1] * weight;
blue += image.bitmap.data[idx + 2] * weight;
alpha += image.bitmap.data[idx + 3] * weight;
wsum += weight;
}
const idx = (y * image.bitmap.width + x) << 2;
image.bitmap.data[idx] = Math.round(red / wsum);
image.bitmap.data[idx + 1] = Math.round(green / wsum);
image.bitmap.data[idx + 2] = Math.round(blue / wsum);
image.bitmap.data[idx + 3] = Math.round(alpha / wsum);
}
}
}
return image;
},
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsD;AAEtD,uCAAuC;AAEvC;;;;;;;;;;;;;;;;;;;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CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBACjE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBACjE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBAEjE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;wBACZ,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;wBAC9D,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,Line truncated
+3
View File
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
+3
View File
@@ -0,0 +1,3 @@
export declare const mulTable: number[];
export declare const shgTable: number[];
//# sourceMappingURL=blur-tables.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"blur-tables.d.ts","sourceRoot":"","sources":["../../src/blur-tables.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAiBpB,CAAC;AAEF,eAAO,MAAM,QAAQ,UAepB,CAAC"}
+35
View File
@@ -0,0 +1,35 @@
export const mulTable = [
1, 57, 41, 21, 203, 34, 97, 73, 227, 91, 149, 62, 105, 45, 39, 137, 241, 107,
3, 173, 39, 71, 65, 238, 219, 101, 187, 87, 81, 151, 141, 133, 249, 117, 221,
209, 197, 187, 177, 169, 5, 153, 73, 139, 133, 127, 243, 233, 223, 107, 103,
99, 191, 23, 177, 171, 165, 159, 77, 149, 9, 139, 135, 131, 253, 245, 119,
231, 224, 109, 211, 103, 25, 195, 189, 23, 45, 175, 171, 83, 81, 79, 155, 151,
147, 9, 141, 137, 67, 131, 129, 251, 123, 30, 235, 115, 113, 221, 217, 53, 13,
51, 50, 49, 193, 189, 185, 91, 179, 175, 43, 169, 83, 163, 5, 79, 155, 19, 75,
147, 145, 143, 35, 69, 17, 67, 33, 65, 255, 251, 247, 243, 239, 59, 29, 229,
113, 111, 219, 27, 213, 105, 207, 51, 201, 199, 49, 193, 191, 47, 93, 183,
181, 179, 11, 87, 43, 85, 167, 165, 163, 161, 159, 157, 155, 77, 19, 75, 37,
73, 145, 143, 141, 35, 138, 137, 135, 67, 33, 131, 129, 255, 63, 250, 247, 61,
121, 239, 237, 117, 29, 229, 227, 225, 111, 55, 109, 216, 213, 211, 209, 207,
205, 203, 201, 199, 197, 195, 193, 48, 190, 47, 93, 185, 183, 181, 179, 178,
176, 175, 173, 171, 85, 21, 167, 165, 41, 163, 161, 5, 79, 157, 78, 154, 153,
19, 75, 149, 74, 147, 73, 144, 143, 71, 141, 140, 139, 137, 17, 135, 134, 133,
66, 131, 65, 129, 1,
];
export const shgTable = [
0, 9, 10, 10, 14, 12, 14, 14, 16, 15, 16, 15, 16, 15, 15, 17, 18, 17, 12, 18,
16, 17, 17, 19, 19, 18, 19, 18, 18, 19, 19, 19, 20, 19, 20, 20, 20, 20, 20,
20, 15, 20, 19, 20, 20, 20, 21, 21, 21, 20, 20, 20, 21, 18, 21, 21, 21, 21,
20, 21, 17, 21, 21, 21, 22, 22, 21, 22, 22, 21, 22, 21, 19, 22, 22, 19, 20,
22, 22, 21, 21, 21, 22, 22, 22, 18, 22, 22, 21, 22, 22, 23, 22, 20, 23, 22,
22, 23, 23, 21, 19, 21, 21, 21, 23, 23, 23, 22, 23, 23, 21, 23, 22, 23, 18,
22, 23, 20, 22, 23, 23, 23, 21, 22, 20, 22, 21, 22, 24, 24, 24, 24, 24, 22,
21, 24, 23, 23, 24, 21, 24, 23, 24, 22, 24, 24, 22, 24, 24, 22, 23, 24, 24,
24, 20, 23, 22, 23, 24, 24, 24, 24, 24, 24, 24, 23, 21, 23, 22, 23, 24, 24,
24, 22, 24, 24, 24, 23, 22, 24, 24, 25, 23, 25, 25, 23, 24, 25, 25, 24, 22,
25, 25, 25, 24, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23,
25, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 22, 25, 25, 23, 25, 25,
20, 24, 25, 24, 25, 25, 22, 24, 25, 24, 25, 24, 25, 25, 24, 25, 25, 25, 25,
22, 25, 25, 25, 24, 25, 24, 25, 18,
];
//# sourceMappingURL=blur-tables.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"blur-tables.js","sourceRoot":"","sources":["../../src/blur-tables.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5E,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5E,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE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,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1E,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1E,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,Line truncated
+30
View File
@@ -0,0 +1,30 @@
import { JimpClass } from "@jimp/types";
export declare const methods: {
/**
* A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.blur(5);
* ```
*/
blur<I extends JimpClass>(image: I, r: number): I;
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.gaussian(15);
* ```
*/
gaussian<I extends JimpClass>(image: I, r: number): I;
};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA+BxC,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;OAWG;SACE,CAAC,SAAS,SAAS,SAAS,CAAC,KAAK,MAAM;IAgI7C;;;;;;;;;;;OAWG;aACM,CAAC,SAAS,SAAS,SAAS,CAAC,KAAK,MAAM;CAiElD,CAAC"}
+208
View File
@@ -0,0 +1,208 @@
import { mulTable, shgTable } from "./blur-tables.js";
import { limit255 } from "@jimp/utils";
/*
Superfast Blur (0.5)
http://www.quasimondo.com/BoxBlurForCanvas/FastBlur.js
Copyright (c) 2011 Mario Klingemann
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
export const methods = {
/**
* A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.blur(5);
* ```
*/
blur(image, r) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
let rsum;
let gsum;
let bsum;
let asum;
let x;
let y;
let i;
let p;
let p1;
let p2;
let yp;
let yi;
let yw;
const wm = image.bitmap.width - 1;
const hm = image.bitmap.height - 1;
// const wh = image.bitmap.width * image.bitmap.height;
const rad1 = r + 1;
const mulSum = mulTable[r];
const shgSum = shgTable[r];
const red = [];
const green = [];
const blue = [];
const alpha = [];
const vmin = [];
const vmax = [];
let iterations = 2;
while (iterations-- > 0) {
yi = 0;
yw = 0;
for (y = 0; y < image.bitmap.height; y++) {
rsum = image.bitmap.data[yw] * rad1;
gsum = image.bitmap.data[yw + 1] * rad1;
bsum = image.bitmap.data[yw + 2] * rad1;
asum = image.bitmap.data[yw + 3] * rad1;
for (i = 1; i <= r; i++) {
p = yw + ((i > wm ? wm : i) << 2);
rsum += image.bitmap.data[p++];
gsum += image.bitmap.data[p++];
bsum += image.bitmap.data[p++];
asum += image.bitmap.data[p];
}
for (x = 0; x < image.bitmap.width; x++) {
red[yi] = rsum;
green[yi] = gsum;
blue[yi] = bsum;
alpha[yi] = asum;
if (y === 0) {
vmin[x] = ((p = x + rad1) < wm ? p : wm) << 2;
vmax[x] = (p = x - r) > 0 ? p << 2 : 0;
}
p1 = yw + vmin[x];
p2 = yw + vmax[x];
rsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
gsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
bsum += image.bitmap.data[p1++] - image.bitmap.data[p2++];
asum += image.bitmap.data[p1] - image.bitmap.data[p2++];
yi++;
}
yw += image.bitmap.width << 2;
}
for (x = 0; x < image.bitmap.width; x++) {
yp = x;
rsum = red[yp] * rad1;
gsum = green[yp] * rad1;
bsum = blue[yp] * rad1;
asum = alpha[yp] * rad1;
for (i = 1; i <= r; i++) {
yp += i > hm ? 0 : image.bitmap.width;
rsum += red[yp];
gsum += green[yp];
bsum += blue[yp];
asum += alpha[yp];
}
yi = x << 2;
for (y = 0; y < image.bitmap.height; y++) {
image.bitmap.data[yi] = limit255((rsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 1] = limit255((gsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 2] = limit255((bsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 3] = limit255((asum * mulSum) >>> shgSum);
if (x === 0) {
vmin[y] = ((p = y + rad1) < hm ? p : hm) * image.bitmap.width;
vmax[y] = (p = y - r) > 0 ? p * image.bitmap.width : 0;
}
p1 = x + vmin[y];
p2 = x + vmax[y];
rsum += red[p1] - red[p2];
gsum += green[p1] - green[p2];
bsum += blue[p1] - blue[p2];
asum += alpha[p1] - alpha[p2];
yi += image.bitmap.width << 2;
}
}
}
return image;
},
// http://blog.ivank.net/fastest-gaussian-blur.html
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.gaussian(15);
* ```
*/
gaussian(image, r) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
const rs = Math.ceil(r * 2.57); // significant radius
const range = rs * 2 + 1;
const rr2 = r * r * 2;
const rr2pi = rr2 * Math.PI;
const weights = [];
for (let y = 0; y < range; y++) {
const weightsRow = [];
for (let x = 0; x < range; x++) {
const dsq = (x - rs) ** 2 + (y - rs) ** 2;
weightsRow[x] = Math.exp(-dsq / rr2) / rr2pi;
}
weights.push(weightsRow);
}
for (let y = 0; y < image.bitmap.height; y++) {
for (let x = 0; x < image.bitmap.width; x++) {
let red = 0;
let green = 0;
let blue = 0;
let alpha = 0;
let wsum = 0;
for (let iy = 0; iy < range; iy++) {
for (let ix = 0; ix < range; ix++) {
const x1 = Math.min(image.bitmap.width - 1, Math.max(0, ix + x - rs));
const y1 = Math.min(image.bitmap.height - 1, Math.max(0, iy + y - rs));
const weight = weights[iy][ix];
const idx = (y1 * image.bitmap.width + x1) << 2;
red += image.bitmap.data[idx] * weight;
green += image.bitmap.data[idx + 1] * weight;
blue += image.bitmap.data[idx + 2] * weight;
alpha += image.bitmap.data[idx + 3] * weight;
wsum += weight;
}
const idx = (y * image.bitmap.width + x) << 2;
image.bitmap.data[idx] = Math.round(red / wsum);
image.bitmap.data[idx + 1] = Math.round(green / wsum);
image.bitmap.data[idx + 2] = Math.round(blue / wsum);
image.bitmap.data[idx + 3] = Math.round(alpha / wsum);
}
}
}
return image;
},
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/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CAAC,EAAE,EAAE,CAAC;oBACzC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBAC7D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBACjE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBACjE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;oBAEjE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;wBACZ,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;wBAC9D,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CLine truncated
+3
View File
@@ -0,0 +1,3 @@
{
"type": "module"
}
+2
View File
@@ -0,0 +1,2 @@
import shared from "@jimp/config-eslint/base.js";
export default [...shared];
+66
View File
@@ -0,0 +1,66 @@
{
"name": "@jimp/plugin-blur",
"version": "1.6.0",
"repository": "jimp-dev/jimp",
"engines": {
"node": ">=18"
},
"scripts": {
"lint": "eslint .",
"test": "vitest",
"build": "tshy",
"dev": "tshy --watch",
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
},
"author": "Andrew Lisowski <lisowski54@gmail.com>",
"license": "MIT",
"dependencies": {
"@jimp/core": "1.6.0",
"@jimp/utils": "1.6.0"
},
"devDependencies": {
"@jimp/config-eslint": "1.6.0",
"@jimp/config-typescript": "1.6.0",
"@jimp/config-vitest": "1.6.0",
"@jimp/js-png": "1.6.0",
"@jimp/test-utils": "1.6.0",
"@jimp/types": "1.6.0",
"@vitest/browser": "^2.0.5",
"eslint": "^9.9.1",
"tshy": "^3.0.2",
"typescript": "^5.5.4",
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^2.0.5"
},
"tshy": {
"exclude": [
"**/*.test.ts"
],
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"type": "module",
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"module": "./dist/esm/index.js",
"gitHead": "c88abe6046dccbdb6e4f5f00c3dd403c81d83515"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

+35
View File
@@ -0,0 +1,35 @@
export const mulTable = [
1, 57, 41, 21, 203, 34, 97, 73, 227, 91, 149, 62, 105, 45, 39, 137, 241, 107,
3, 173, 39, 71, 65, 238, 219, 101, 187, 87, 81, 151, 141, 133, 249, 117, 221,
209, 197, 187, 177, 169, 5, 153, 73, 139, 133, 127, 243, 233, 223, 107, 103,
99, 191, 23, 177, 171, 165, 159, 77, 149, 9, 139, 135, 131, 253, 245, 119,
231, 224, 109, 211, 103, 25, 195, 189, 23, 45, 175, 171, 83, 81, 79, 155, 151,
147, 9, 141, 137, 67, 131, 129, 251, 123, 30, 235, 115, 113, 221, 217, 53, 13,
51, 50, 49, 193, 189, 185, 91, 179, 175, 43, 169, 83, 163, 5, 79, 155, 19, 75,
147, 145, 143, 35, 69, 17, 67, 33, 65, 255, 251, 247, 243, 239, 59, 29, 229,
113, 111, 219, 27, 213, 105, 207, 51, 201, 199, 49, 193, 191, 47, 93, 183,
181, 179, 11, 87, 43, 85, 167, 165, 163, 161, 159, 157, 155, 77, 19, 75, 37,
73, 145, 143, 141, 35, 138, 137, 135, 67, 33, 131, 129, 255, 63, 250, 247, 61,
121, 239, 237, 117, 29, 229, 227, 225, 111, 55, 109, 216, 213, 211, 209, 207,
205, 203, 201, 199, 197, 195, 193, 48, 190, 47, 93, 185, 183, 181, 179, 178,
176, 175, 173, 171, 85, 21, 167, 165, 41, 163, 161, 5, 79, 157, 78, 154, 153,
19, 75, 149, 74, 147, 73, 144, 143, 71, 141, 140, 139, 137, 17, 135, 134, 133,
66, 131, 65, 129, 1,
];
export const shgTable = [
0, 9, 10, 10, 14, 12, 14, 14, 16, 15, 16, 15, 16, 15, 15, 17, 18, 17, 12, 18,
16, 17, 17, 19, 19, 18, 19, 18, 18, 19, 19, 19, 20, 19, 20, 20, 20, 20, 20,
20, 15, 20, 19, 20, 20, 20, 21, 21, 21, 20, 20, 20, 21, 18, 21, 21, 21, 21,
20, 21, 17, 21, 21, 21, 22, 22, 21, 22, 22, 21, 22, 21, 19, 22, 22, 19, 20,
22, 22, 21, 21, 21, 22, 22, 22, 18, 22, 22, 21, 22, 22, 23, 22, 20, 23, 22,
22, 23, 23, 21, 19, 21, 21, 21, 23, 23, 23, 22, 23, 23, 21, 23, 22, 23, 18,
22, 23, 20, 22, 23, 23, 23, 21, 22, 20, 22, 21, 22, 24, 24, 24, 24, 24, 22,
21, 24, 23, 23, 24, 21, 24, 23, 24, 22, 24, 24, 22, 24, 24, 22, 23, 24, 24,
24, 20, 23, 22, 23, 24, 24, 24, 24, 24, 24, 24, 23, 21, 23, 22, 23, 24, 24,
24, 22, 24, 24, 24, 23, 22, 24, 24, 25, 23, 25, 25, 23, 24, 25, 25, 24, 22,
25, 25, 25, 24, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23,
25, 23, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 22, 25, 25, 23, 25, 25,
20, 24, 25, 24, 25, 25, 22, 24, 25, 24, 25, 24, 25, 25, 24, 25, 25, 25, 25,
22, 25, 25, 25, 24, 25, 24, 25, 18,
];
+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, test } from "vitest";
import { createJimp } from "@jimp/core";
import { getTestImagePath } from "@jimp/test-utils";
import "@jimp/test-utils/image-snapshot";
import png from "@jimp/js-png";
import * as blur from "./index.js";
const Jimp = createJimp({ formats: [png], plugins: [blur.methods] });
describe("hasAlpha", () => {
test("image with alpha", async () => {
const image = await Jimp.read(getTestImagePath("dice.png"));
const output = await image.blur(16).getBuffer("image/png");
expect(output).toMatchImageSnapshot();
});
});
+251
View File
@@ -0,0 +1,251 @@
import { mulTable, shgTable } from "./blur-tables.js";
import { JimpClass } from "@jimp/types";
import { limit255 } from "@jimp/utils";
/*
Superfast Blur (0.5)
http://www.quasimondo.com/BoxBlurForCanvas/FastBlur.js
Copyright (c) 2011 Mario Klingemann
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
export const methods = {
/**
* A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.blur(5);
* ```
*/
blur<I extends JimpClass>(image: I, r: number) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
let rsum: number;
let gsum: number;
let bsum: number;
let asum: number;
let x: number;
let y: number;
let i: number;
let p: number;
let p1: number;
let p2: number;
let yp: number;
let yi: number;
let yw: number;
const wm = image.bitmap.width - 1;
const hm = image.bitmap.height - 1;
// const wh = image.bitmap.width * image.bitmap.height;
const rad1 = r + 1;
const mulSum = mulTable[r]!;
const shgSum = shgTable[r]!;
const red = [];
const green = [];
const blue = [];
const alpha = [];
const vmin = [];
const vmax = [];
let iterations = 2;
while (iterations-- > 0) {
yi = 0;
yw = 0;
for (y = 0; y < image.bitmap.height; y++) {
rsum = image.bitmap.data[yw]! * rad1;
gsum = image.bitmap.data[yw + 1]! * rad1;
bsum = image.bitmap.data[yw + 2]! * rad1;
asum = image.bitmap.data[yw + 3]! * rad1;
for (i = 1; i <= r; i++) {
p = yw + ((i > wm ? wm : i) << 2);
rsum += image.bitmap.data[p++]!;
gsum += image.bitmap.data[p++]!;
bsum += image.bitmap.data[p++]!;
asum += image.bitmap.data[p]!;
}
for (x = 0; x < image.bitmap.width; x++) {
red[yi] = rsum;
green[yi] = gsum;
blue[yi] = bsum;
alpha[yi] = asum;
if (y === 0) {
vmin[x] = ((p = x + rad1) < wm ? p : wm) << 2;
vmax[x] = (p = x - r) > 0 ? p << 2 : 0;
}
p1 = yw + vmin[x]!;
p2 = yw + vmax[x]!;
rsum += image.bitmap.data[p1++]! - image.bitmap.data[p2++]!;
gsum += image.bitmap.data[p1++]! - image.bitmap.data[p2++]!;
bsum += image.bitmap.data[p1++]! - image.bitmap.data[p2++]!;
asum += image.bitmap.data[p1]! - image.bitmap.data[p2++]!;
yi++;
}
yw += image.bitmap.width << 2;
}
for (x = 0; x < image.bitmap.width; x++) {
yp = x;
rsum = red[yp]! * rad1;
gsum = green[yp]! * rad1;
bsum = blue[yp]! * rad1;
asum = alpha[yp]! * rad1;
for (i = 1; i <= r; i++) {
yp += i > hm ? 0 : image.bitmap.width;
rsum += red[yp]!;
gsum += green[yp]!;
bsum += blue[yp]!;
asum += alpha[yp]!;
}
yi = x << 2;
for (y = 0; y < image.bitmap.height; y++) {
image.bitmap.data[yi] = limit255((rsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 1] = limit255((gsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 2] = limit255((bsum * mulSum) >>> shgSum);
image.bitmap.data[yi + 3] = limit255((asum * mulSum) >>> shgSum);
if (x === 0) {
vmin[y] = ((p = y + rad1) < hm ? p : hm) * image.bitmap.width;
vmax[y] = (p = y - r) > 0 ? p * image.bitmap.width : 0;
}
p1 = x + vmin[y]!;
p2 = x + vmax[y]!;
rsum += red[p1]! - red[p2]!;
gsum += green[p1]! - green[p2]!;
bsum += blue[p1]! - blue[p2]!;
asum += alpha[p1]! - alpha[p2]!;
yi += image.bitmap.width << 2;
}
}
}
return image;
},
// http://blog.ivank.net/fastest-gaussian-blur.html
/**
* Applies a true Gaussian blur to the image (warning: this is VERY slow)
* @param r the pixel radius of the blur
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.gaussian(15);
* ```
*/
gaussian<I extends JimpClass>(image: I, r: number) {
if (typeof r !== "number") {
throw new Error("r must be a number");
}
if (r < 1) {
throw new Error("r must be greater than 0");
}
const rs = Math.ceil(r * 2.57); // significant radius
const range = rs * 2 + 1;
const rr2 = r * r * 2;
const rr2pi = rr2 * Math.PI;
const weights = [];
for (let y = 0; y < range; y++) {
const weightsRow = [];
for (let x = 0; x < range; x++) {
const dsq = (x - rs) ** 2 + (y - rs) ** 2;
weightsRow[x] = Math.exp(-dsq / rr2) / rr2pi;
}
weights.push(weightsRow);
}
for (let y = 0; y < image.bitmap.height; y++) {
for (let x = 0; x < image.bitmap.width; x++) {
let red = 0;
let green = 0;
let blue = 0;
let alpha = 0;
let wsum = 0;
for (let iy = 0; iy < range; iy++) {
for (let ix = 0; ix < range; ix++) {
const x1 = Math.min(
image.bitmap.width - 1,
Math.max(0, ix + x - rs)
);
const y1 = Math.min(
image.bitmap.height - 1,
Math.max(0, iy + y - rs)
);
const weight = weights[iy]![ix]!;
const idx = (y1 * image.bitmap.width + x1) << 2;
red += image.bitmap.data[idx]! * weight;
green += image.bitmap.data[idx + 1]! * weight;
blue += image.bitmap.data[idx + 2]! * weight;
alpha += image.bitmap.data[idx + 3]! * weight;
wsum += weight;
}
const idx = (y * image.bitmap.width + x) << 2;
image.bitmap.data[idx] = Math.round(red / wsum);
image.bitmap.data[idx + 1] = Math.round(green / wsum);
image.bitmap.data[idx + 2] = Math.round(blue / wsum);
image.bitmap.data[idx + 3] = Math.round(alpha / wsum);
}
}
}
return image;
},
};
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "@jimp/config-typescript/base.json",
"compilerOptions": {
"outDir": "dist"
}
}
+3
View File
@@ -0,0 +1,3 @@
import config from "@jimp/config-vitest/browser";
export default config;