chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+82
@@ -0,0 +1,82 @@
|
||||
# v0.22.1 (Mon Feb 06 2023)
|
||||
|
||||
#### 🏠 Internal
|
||||
|
||||
- rename master to main [#1169](https://github.com/jimp-dev/jimp/pull/1169) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v0.21.0 (Sun Feb 05 2023)
|
||||
|
||||
### Release Notes
|
||||
|
||||
#### Babel Refactor ([#1149](https://github.com/jimp-dev/jimp/pull/1149))
|
||||
|
||||
Marking this as a "breaking release" because it might change what deps need to be installed.
|
||||
|
||||
All modules should be exported as valid cjs and esm
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### 💥 Breaking Change
|
||||
|
||||
- Babel Refactor [#1149](https://github.com/jimp-dev/jimp/pull/1149) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v0.16.3 (Sat Feb 04 2023)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v0.11.0 (Fri May 15 2020)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- Removed Core-JS as a dependency. [#882](https://github.com/oliver-moran/jimp/pull/882) ([@EricRabil](https://github.com/EricRabil))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Eric Rabil ([@EricRabil](https://github.com/EricRabil))
|
||||
|
||||
---
|
||||
|
||||
# v0.10.1 (Sun Apr 05 2020)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Update package.json [#870](https://github.com/oliver-moran/jimp/pull/870) ([@arcanis](https://github.com/arcanis))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Maël Nison ([@arcanis](https://github.com/arcanis))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.3 (Tue Nov 26 2019)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
|
||||
+21
@@ -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.
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<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/utils</h1>
|
||||
<p>Utils for jimp extensions.</p>
|
||||
</div>
|
||||
|
||||
## Available Methods
|
||||
|
||||
### isNodePattern
|
||||
|
||||
Determines if function was passed an node callback.
|
||||
|
||||
```js
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
```
|
||||
|
||||
### throwError
|
||||
|
||||
Either throws the error or calls the callback with the error.
|
||||
|
||||
```js
|
||||
if (/* check for error */) {
|
||||
return throwError.call(this, 'someError', cb);
|
||||
}
|
||||
```
|
||||
|
||||
### scan
|
||||
|
||||
Scans through a region of the bitmap, calling a function for each pixel.
|
||||
|
||||
```js
|
||||
function removeRed(image) {
|
||||
return scan(
|
||||
image,
|
||||
0,
|
||||
0,
|
||||
image.bitmap.width,
|
||||
image.bitmap.height,
|
||||
function (x, y, index) {
|
||||
const red = this.bitmap.data[index + 0];
|
||||
const green = this.bitmap.data[index + 1];
|
||||
const blue = this.bitmap.data[index + 2];
|
||||
const alpha = this.bitmap.data[index + 3];
|
||||
|
||||
this.bitmap.data[index + 0] = 0;
|
||||
this.bitmap.data[index + 1] = green;
|
||||
this.bitmap.data[index + 2] = blue;
|
||||
this.bitmap.data[index + 3] = alpha;
|
||||
}
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### scanIterator
|
||||
|
||||
It's possible to make an iterator scan with a `for ... of`, if you want to `break` the scan before it reaches the end, but note, that this iterator has a huge performance implication:
|
||||
|
||||
```js
|
||||
for (const { x, y, idx, image } of scanIterator(
|
||||
image,
|
||||
0,
|
||||
0,
|
||||
image.bitmap.width,
|
||||
image.bitmap.height
|
||||
)) {
|
||||
}
|
||||
```
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
export function isNodePattern(cb) {
|
||||
if (typeof cb === "undefined") {
|
||||
return false;
|
||||
}
|
||||
if (typeof cb !== "function") {
|
||||
throw new TypeError("Callback must be a function");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
export function throwError(error, cb) {
|
||||
if (typeof error === "string") {
|
||||
error = new Error(error);
|
||||
}
|
||||
if (typeof cb === "function") {
|
||||
return cb.call(this, error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
export function scan(image, x, y, w, h, f) {
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
w = Math.round(w);
|
||||
h = Math.round(h);
|
||||
for (let _y = y; _y < y + h; _y++) {
|
||||
for (let _x = x; _x < x + w; _x++) {
|
||||
const idx = image.bitmap.width * _y + _x << 2;
|
||||
f.call(image, _x, _y, idx);
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
export function* scanIterator(image, x, y, w, h) {
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
w = Math.round(w);
|
||||
h = Math.round(h);
|
||||
for (let _y = y; _y < y + h; _y++) {
|
||||
for (let _x = x; _x < x + w; _x++) {
|
||||
const idx = image.bitmap.width * _y + _x << 2;
|
||||
yield {
|
||||
x: _x,
|
||||
y: _y,
|
||||
idx,
|
||||
image
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["isNodePattern","cb","TypeError","throwError","error","Error","call","scan","image","x","y","w","h","f","Math","round","_y","_x","idx","bitmap","width","scanIterator"],"sources":["../src/index.js"],"sourcesContent":["export function isNodePattern(cb) {\n if (typeof cb === \"undefined\") {\n return false;\n }\n\n if (typeof cb !== \"function\") {\n throw new TypeError(\"Callback must be a function\");\n }\n\n return true;\n}\n\nexport function throwError(error, cb) {\n if (typeof error === \"string\") {\n error = new Error(error);\n }\n\n if (typeof cb === \"function\") {\n return cb.call(this, error);\n }\n\n throw error;\n}\n\nexport function scan(image, x, y, w, h, f) {\n // round input\n x = Math.round(x);\n y = Math.round(y);\n w = Math.round(w);\n h = Math.round(h);\n\n for (let _y = y; _y < y + h; _y++) {\n for (let _x = x; _x < x + w; _x++) {\n const idx = (image.bitmap.width * _y + _x) << 2;\n f.call(image, _x, _y, idx);\n }\n }\n\n return image;\n}\n\nexport function* scanIterator(image, x, y, w, h) {\n // round input\n x = Math.round(x);\n y = Math.round(y);\n w = Math.round(w);\n h = Math.round(h);\n\n for (let _y = y; _y < y + h; _y++) {\n for (let _x = x; _x < x + w; _x++) {\n const idx = (image.bitmap.width * _y + _x) << 2;\n yield { x: _x, y: _y, idx, image };\n }\n }\n}\n"],"mappings":"AAAA,OAAO,SAASA,aAAa,CAACC,EAAE,EAAE;EAChC,IAAI,OAAOA,EAAE,KAAK,WAAW,EAAE;IAC7B,OAAO,KAAK;EACd;EAEA,IAAI,OAAOA,EAAE,KAAK,UAAU,EAAE;IAC5B,MAAM,IAAIC,SAAS,CAAC,6BAA6B,CAAC;EACpD;EAEA,OAAO,IAAI;AACb;AAEA,OAAO,SAASC,UAAU,CAACC,KAAK,EAAEH,EAAE,EAAE;EACpC,IAAI,OAAOG,KAAK,KAAK,QAAQ,EAAE;IAC7BA,KAAK,GAAG,IAAIC,KAAK,CAACD,KAAK,CAAC;EAC1B;EAEA,IAAI,OAAOH,EAAE,KAAK,UAAU,EAAE;IAC5B,OAAOA,EAAE,CAACK,IAAI,CAAC,IAAI,EAAEF,KAAK,CAAC;EAC7B;EAEA,MAAMA,KAAK;AACb;AAEA,OAAO,SAASG,IAAI,CAACC,KAAK,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAE;EACzC;EACAJ,CAAC,GAAGK,IAAI,CAACC,KAAK,CAACN,CAAC,CAAC;EACjBC,CAAC,GAAGI,IAAI,CAACC,KAAK,CAACL,CAAC,CAAC;EACjBC,CAAC,GAAGG,IAA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V;MAAM,CAAC;IACpC;EACF;AACF"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { Image, Omit } from "@jimp/core";
|
||||
import { ThrowStatement } from "typescript";
|
||||
|
||||
export function isNodePattern(cb: Function): true;
|
||||
export function isNodePattern(cb: Omit<any, Function>): false;
|
||||
|
||||
export function throwError(
|
||||
error: string | Error,
|
||||
cb?: (err: Error) => void
|
||||
): ThrowStatement;
|
||||
|
||||
export function scan(
|
||||
image: Image,
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number,
|
||||
f: (image: Image, _x: number, _y: number, idx: number) => void
|
||||
): Image;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@jimp/utils",
|
||||
"version": "0.22.12",
|
||||
"description": "Utils for jimp extensions.",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"scripts": {
|
||||
"build": "npm run build:node:production && npm run build:module",
|
||||
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
|
||||
"build:debug": "npm run build:node:debug",
|
||||
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
|
||||
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
|
||||
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
|
||||
"build:node:production": "cross-env BABEL_ENV=production npm run build:node"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"regenerator-runtime": "^0.13.3"
|
||||
},
|
||||
"gitHead": "a4a8d6364bbf97629749e196f3b0a4c94c9a7abc"
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
export function isNodePattern(cb) {
|
||||
if (typeof cb === "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof cb !== "function") {
|
||||
throw new TypeError("Callback must be a function");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function throwError(error, cb) {
|
||||
if (typeof error === "string") {
|
||||
error = new Error(error);
|
||||
}
|
||||
|
||||
if (typeof cb === "function") {
|
||||
return cb.call(this, error);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
export function scan(image, x, y, w, h, f) {
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
w = Math.round(w);
|
||||
h = Math.round(h);
|
||||
|
||||
for (let _y = y; _y < y + h; _y++) {
|
||||
for (let _x = x; _x < x + w; _x++) {
|
||||
const idx = (image.bitmap.width * _y + _x) << 2;
|
||||
f.call(image, _x, _y, idx);
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
export function* scanIterator(image, x, y, w, h) {
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
w = Math.round(w);
|
||||
h = Math.round(h);
|
||||
|
||||
for (let _y = y; _y < y + h; _y++) {
|
||||
for (let _x = x; _x < x + w; _x++) {
|
||||
const idx = (image.bitmap.width * _y + _x) << 2;
|
||||
yield { x: _x, y: _y, idx, image };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user