chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
# 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.22.0 (Mon Feb 06 2023)
|
||||
|
||||
#### 🏠 Internal
|
||||
|
||||
- switch from should to expect [#1163](https://github.com/jimp-dev/jimp/pull/1163) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Change test matching strategy to include all test files [#1161](https://github.com/jimp-dev/jimp/pull/1161) ([@danielholmes](https://github.com/danielholmes))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Daniel Holmes ([@danielholmes](https://github.com/danielholmes))
|
||||
|
||||
---
|
||||
|
||||
# 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.16.2 (Thu Sep 15 2022)
|
||||
|
||||
#### 📝 Documentation
|
||||
|
||||
- added the "e" back to @jimp/plugin-fisheye [#947](https://github.com/oliver-moran/jimp/pull/947) ([@mynameismax](https://github.com/mynameismax))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Max ([@mynameismax](https://github.com/mynameismax))
|
||||
|
||||
---
|
||||
|
||||
# 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.9.3 (Tue Nov 26 2019)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
|
||||
- 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.
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<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-fisheye</h1>
|
||||
<p>Apply a fisheye effect to an image</p>
|
||||
</div>
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {function(Error, Jimp)} options (optional) radius
|
||||
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
|
||||
```js
|
||||
import jimp from "jimp";
|
||||
|
||||
async function main() {
|
||||
const image = await jimp.read("test/image.png");
|
||||
|
||||
image.fisheye();
|
||||
// or
|
||||
image.fisheye({ r: 1.6 });
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
Produces nice images with [@jimp/plugin-circle](../plugin-circle).
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
module.exports = (api) => {
|
||||
api.cache(true);
|
||||
|
||||
return {
|
||||
presets: [
|
||||
[
|
||||
"@babel/env",
|
||||
{
|
||||
useBuiltIns: "usage",
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
plugins: [
|
||||
"@babel/proposal-class-properties",
|
||||
"@babel/syntax-object-rest-spread",
|
||||
process.env.BABEL_ENV !== "module" && "add-module-exports",
|
||||
[
|
||||
"transform-inline-environment-variables",
|
||||
{ include: ["BABEL_ENV", "ENV"] },
|
||||
],
|
||||
].filter(Boolean),
|
||||
|
||||
env: {
|
||||
test: {
|
||||
plugins: ["istanbul"],
|
||||
},
|
||||
development: {
|
||||
plugins: [process.env.ENV !== "browser" && "source-map-support"].filter(
|
||||
Boolean
|
||||
),
|
||||
},
|
||||
module: {
|
||||
presets: [["@babel/env", { modules: false }]],
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import { isNodePattern } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {object} options (optional) r: radius of effect
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default (() => ({
|
||||
fisheye() {
|
||||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
||||
r: 2.5
|
||||
};
|
||||
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
||||
if (typeof options === "function") {
|
||||
cb = options;
|
||||
options = {
|
||||
r: 2.5
|
||||
};
|
||||
}
|
||||
const source = this.cloneQuiet();
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = source.bitmap;
|
||||
source.scanQuiet(0, 0, width, height, (x, y) => {
|
||||
const hx = x / width;
|
||||
const hy = y / height;
|
||||
const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));
|
||||
const rn = 2 * Math.pow(r, options.r);
|
||||
const cosA = (hx - 0.5) / r;
|
||||
const sinA = (hy - 0.5) / r;
|
||||
const newX = Math.round((rn * cosA + 0.5) * width);
|
||||
const newY = Math.round((rn * sinA + 0.5) * height);
|
||||
const color = source.getPixelColor(newX, newY);
|
||||
this.setPixelColor(color, x, y);
|
||||
});
|
||||
|
||||
/* Set center pixel color, otherwise it will be transparent */
|
||||
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2);
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}));
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["isNodePattern","fisheye","options","r","cb","source","cloneQuiet","width","height","bitmap","scanQuiet","x","y","hx","hy","Math","sqrt","pow","rn","cosA","sinA","newX","round","newY","color","getPixelColor","setPixelColor","call"],"sources":["../src/index.js"],"sourcesContent":["import { isNodePattern } from \"@jimp/utils\";\n\n/**\n * Creates a circle out of an image.\n * @param {object} options (optional) r: radius of effect\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n fisheye(options = { r: 2.5 }, cb) {\n if (typeof options === \"function\") {\n cb = options;\n options = { r: 2.5 };\n }\n\n const source = this.cloneQuiet();\n const { width, height } = source.bitmap;\n\n source.scanQuiet(0, 0, width, height, (x, y) => {\n const hx = x / width;\n const hy = y / height;\n const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));\n const rn = 2 * Math.pow(r, options.r);\n const cosA = (hx - 0.5) / r;\n const sinA = (hy - 0.5) / r;\n const newX = Math.round((rn * cosA + 0.5) * width);\n const newY = Math.round((rn * sinA + 0.5) * height);\n const color = source.getPixelColor(newX, newY);\n\n this.setPixelColor(color, x, y);\n });\n\n /* Set center pixel color, otherwise it will be transparent */\n this.setPixelColor(\n source.getPixelColor(width / 2, height / 2),\n width / 2,\n height / 2\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;EACpBC,OAAO,GAA2B;IAAA,IAA1BC,OAAO,uEAAG;MAAEC,CAAC,EAAE;IAAI,CAAC;IAAA,IAAEC,EAAE;IAC9B,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;MACjCE,EAAE,GAAGF,OAAO;MACZA,OAAO,GAAG;QAAEC,CAAC,EAAE;MAAI,CAAC;IACtB;IAEA,MAAME,MAAM,GAAG,IAAI,CAACC,UAAU,EAAE;IAChC,MAAM;MAAEC,KAAK;MAAEC;IAAO,CAAC,GAAGH,MAAM,CAACI,MAAM;IAEvCJ,MAAM,CAACK,SAAS,CAAC,CAAC,EAAE,CAAC,EAAEH,KAAK,EAAEC,MAAM,EAAE,CAACG,CAAC,EAAEC,CAAC,KAAK;MAC9C,MAAMC,EAAE,GAAGF,CAAC,GAAGJ,KAAK;MACpB,MAAMO,EAAE,GAAGF,CAAC,GAAGJ,MAAM;MACrB,MAAML,CAAC,GAAGY,IAAI,CAACC,IAAI,CAACD,IAAI,CAACE,GAAG,CAACJ,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,GAAGE,IAAI,CAACE,GAAG,CAACH,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;MAClE,MAAMI,EAAE,GAAG,CAAC,GAAGH,IAAI,CAACE,GAAG,CAACd,CAAC,EAAED,OAAO,CAACC,CAAC,CAAC;MACrC,MAAMgB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAG,IAAIV,CAAC;MAC3B,MAAMiB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAG,IAAIX,CAAC;MAC3B,MAAMkB,IAAI,GAAGN,IAAI,CAACO,KAAK,CAAC,CAACJ,EAAE,GAAGC,IAAI,GAAG,GAAG,IAAIZ,KAAK,CAAC;MAClD,MAAMgB,IAAI,GAAGR,IAAI,CAACO,KAAK,CAAC,CAACJ,EAAE,GAAGE,IAAI,GAAG,GAAG,IAAIZ,MAAM,CAAC;MACnD,MAAMgB,KAAK,GAAGnB,MAAM,CAACoB,aAAa,CAACJ,IAAI,EAAEE,IAAI,CAAC;MAE9C,IAAI,CAACG,aAAa,CAACF,KAAK,EAAEb,CAAC,EAAEC,CAAC,CAAC;IACjC,CAAC,CAAC;;IAEF;IACA,IAAI,CAACc,aAAa,CAChBrB,MAAM,CAACoB,aAAa,CAAClB,KAAK,GAAG,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,EAC3CD,KAAK,GAAG,CAAC,EACTC,MAAM,GAAG,CAAC,CACX;IAED,IAAIR,aAAa,CAACI,EAAE,CAAC,EAAE;MACrBA,EAAE,CAACuB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3B;IAEA,OAAO,IAAI;EACb;AACF,CAAC,CAAC"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { ImageCallback } from "@jimp/core";
|
||||
|
||||
interface Fisheye {
|
||||
fishEye(opts?: { r: number }, cb?: ImageCallback<this>): this;
|
||||
fishEye(cb?: ImageCallback<this>): this;
|
||||
}
|
||||
|
||||
export default function (): Fisheye;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@jimp/plugin-fisheye",
|
||||
"version": "0.22.12",
|
||||
"description": "Apply a fisheye effect to an image.",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register --recursive test --extension js",
|
||||
"test:watch": "npm run test -- --reporter min --watch",
|
||||
"test:coverage": "nyc npm run test",
|
||||
"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",
|
||||
"dependencies": {
|
||||
"@jimp/utils": "^0.22.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.22.12",
|
||||
"@jimp/test-utils": "^0.22.12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "a4a8d6364bbf97629749e196f3b0a4c94c9a7abc"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import { isNodePattern } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {object} options (optional) r: radius of effect
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
fisheye(options = { r: 2.5 }, cb) {
|
||||
if (typeof options === "function") {
|
||||
cb = options;
|
||||
options = { r: 2.5 };
|
||||
}
|
||||
|
||||
const source = this.cloneQuiet();
|
||||
const { width, height } = source.bitmap;
|
||||
|
||||
source.scanQuiet(0, 0, width, height, (x, y) => {
|
||||
const hx = x / width;
|
||||
const hy = y / height;
|
||||
const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));
|
||||
const rn = 2 * Math.pow(r, options.r);
|
||||
const cosA = (hx - 0.5) / r;
|
||||
const sinA = (hy - 0.5) / r;
|
||||
const newX = Math.round((rn * cosA + 0.5) * width);
|
||||
const newY = Math.round((rn * sinA + 0.5) * height);
|
||||
const color = source.getPixelColor(newX, newY);
|
||||
|
||||
this.setPixelColor(color, x, y);
|
||||
});
|
||||
|
||||
/* Set center pixel color, otherwise it will be transparent */
|
||||
this.setPixelColor(
|
||||
source.getPixelColor(width / 2, height / 2),
|
||||
width / 2,
|
||||
height / 2
|
||||
);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
});
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
import { Jimp, mkJGD } from "@jimp/test-utils";
|
||||
import configure from "@jimp/custom";
|
||||
|
||||
import fisheye from "../src";
|
||||
import { expectToBeJGD } from "@jimp/test-utils/src";
|
||||
|
||||
const jimp = configure({ plugins: [fisheye] }, Jimp);
|
||||
|
||||
describe("Fisheye", () => {
|
||||
it("should create fisheye lens to image", async () => {
|
||||
const imgNormal = await jimp.read(
|
||||
mkJGD(
|
||||
"0000000000",
|
||||
"0001221000",
|
||||
"0022222200",
|
||||
"0122112210",
|
||||
"0221001220",
|
||||
"0221001220",
|
||||
"0122112210",
|
||||
"0022222200",
|
||||
"0001221000",
|
||||
"0000000000"
|
||||
)
|
||||
);
|
||||
const imgBulged = await jimp.read(
|
||||
mkJGD(
|
||||
"0001221000",
|
||||
"0221112220",
|
||||
"0220000121",
|
||||
"1100000112",
|
||||
"2100000012",
|
||||
"2100000012",
|
||||
"1200000012",
|
||||
"0211000222",
|
||||
"0221111220",
|
||||
"0012222200"
|
||||
)
|
||||
);
|
||||
|
||||
expectToBeJGD(imgNormal.fisheye().getJGDSync(), imgBulged.getJGDSync());
|
||||
});
|
||||
|
||||
it("should create fisheye lens to image with radius", async () => {
|
||||
const imgNormal = await jimp.read(
|
||||
mkJGD(
|
||||
"0000000000",
|
||||
"0000000000",
|
||||
"0000000000",
|
||||
"0000000000",
|
||||
"0001111000",
|
||||
"0001111000",
|
||||
"0000000000",
|
||||
"0000000000",
|
||||
"0000000000",
|
||||
"0000000000"
|
||||
)
|
||||
);
|
||||
const imgBulged = await jimp.read(
|
||||
mkJGD(
|
||||
"■■■■■■■■■■",
|
||||
"■■■■■■■■■■",
|
||||
"■■■■■■■■■■",
|
||||
"■■■11111■■",
|
||||
"■■111111■■",
|
||||
"■■111111■■",
|
||||
"■■■■111■■■",
|
||||
"■■■■■■■■■■",
|
||||
"■■■■■■■■■■",
|
||||
"■■■■■■■■■■"
|
||||
)
|
||||
);
|
||||
|
||||
expectToBeJGD(
|
||||
imgNormal.fisheye({ r: 1.8 }).getJGDSync(),
|
||||
imgBulged.getJGDSync()
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user