chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+154
@@ -0,0 +1,154 @@
|
||||
# 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.17.0 (Sat Feb 04 2023)
|
||||
|
||||
### Release Notes
|
||||
|
||||
#### update jpeg-js ([#1131](https://github.com/jimp-dev/jimp/pull/1131))
|
||||
|
||||
This release changes the minimum node version from 8 to 16
|
||||
|
||||
---
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- update jpeg-js [#1131](https://github.com/jimp-dev/jimp/pull/1131) ([@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)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Bump jpeg-js over 0.4.4 to avoid cve-2022-25851 [#1093](https://github.com/oliver-moran/jimp/pull/1093) ([@melhadad](https://github.com/melhadad))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Michael Elhadad ([@melhadad](https://github.com/melhadad))
|
||||
|
||||
---
|
||||
|
||||
# v0.16.1 (Fri Aug 28 2020)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- upgrade jpeg-js dependency [#933](https://github.com/oliver-moran/jimp/pull/933) (vincentdufrasnes@vincent-dufrasnes [@Chupsy](https://github.com/Chupsy))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Vincent Dufrasnes ([@Chupsy](https://github.com/Chupsy))
|
||||
- vincent dufrasnes (vincentdufrasnes@vincent-dufrasnes)
|
||||
|
||||
---
|
||||
|
||||
# v0.12.1 (Tue May 19 2020)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- update jpeg-js [#892](https://github.com/oliver-moran/jimp/pull/892) ([@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.0 (Mon Mar 30 2020)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- Properly split constructor and instance types [#867](https://github.com/oliver-moran/jimp/pull/867) ([@forivall](https://github.com/forivall))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Emily Marigold Klassen ([@forivall](https://github.com/forivall))
|
||||
|
||||
---
|
||||
|
||||
# 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.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<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/jpeg</h1>
|
||||
<p>Default Jimp jpeg encoder/decoder.</p>
|
||||
</div>
|
||||
|
||||
## Available Methods
|
||||
|
||||
### Jimp.quality
|
||||
|
||||
Sets the quality of the image when saving as JPEG format (default is 100)
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import JPEG from "jpeg-js";
|
||||
import { throwError, isNodePattern } from "@jimp/utils";
|
||||
const MIME_TYPE = "image/jpeg";
|
||||
export default (() => ({
|
||||
mime: {
|
||||
[MIME_TYPE]: ["jpeg", "jpg", "jpe"]
|
||||
},
|
||||
constants: {
|
||||
MIME_JPEG: MIME_TYPE
|
||||
},
|
||||
decoders: {
|
||||
[MIME_TYPE]: JPEG.decode
|
||||
},
|
||||
encoders: {
|
||||
[MIME_TYPE]: image => JPEG.encode(image.bitmap, image._quality).data
|
||||
},
|
||||
class: {
|
||||
// The quality to be used when saving JPEG images
|
||||
_quality: 100,
|
||||
/**
|
||||
* Sets the quality of the image when saving as JPEG format (default is 100)
|
||||
* @param {number} n The quality to use 0-100
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
quality(n, cb) {
|
||||
if (typeof n !== "number") {
|
||||
return throwError.call(this, "n must be a number", cb);
|
||||
}
|
||||
if (n < 0 || n > 100) {
|
||||
return throwError.call(this, "n must be a number 0 - 100", cb);
|
||||
}
|
||||
this._quality = Math.round(n);
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}));
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["JPEG","throwError","isNodePattern","MIME_TYPE","mime","constants","MIME_JPEG","decoders","decode","encoders","image","encode","bitmap","_quality","data","class","quality","n","cb","call","Math","round"],"sources":["../src/index.js"],"sourcesContent":["import JPEG from \"jpeg-js\";\nimport { throwError, isNodePattern } from \"@jimp/utils\";\n\nconst MIME_TYPE = \"image/jpeg\";\n\nexport default () => ({\n mime: { [MIME_TYPE]: [\"jpeg\", \"jpg\", \"jpe\"] },\n\n constants: {\n MIME_JPEG: MIME_TYPE,\n },\n\n decoders: {\n [MIME_TYPE]: JPEG.decode,\n },\n\n encoders: {\n [MIME_TYPE]: (image) => JPEG.encode(image.bitmap, image._quality).data,\n },\n\n class: {\n // The quality to be used when saving JPEG images\n _quality: 100,\n /**\n * Sets the quality of the image when saving as JPEG format (default is 100)\n * @param {number} n The quality to use 0-100\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\n quality(n, cb) {\n if (typeof n !== \"number\") {\n return throwError.call(this, \"n must be a number\", cb);\n }\n\n if (n < 0 || n > 100) {\n return throwError.call(this, \"n must be a number 0 - 100\", cb);\n }\n\n this._quality = Math.round(n);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,SAASC,UAAU,EAAEC,aAAa,QAAQ,aAAa;AAEvD,MAAMC,SAAS,GAAG,YAAY;AAE9B,gBAAe,OAAO;EACpBC,IAAI,EAAE;IAAE,CAACD,SAAS,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK;EAAE,CAAC;EAE7CE,SAAS,EAAE;IACTC,SAAS,EAAEH;EACb,CAAC;EAEDI,QAAQ,EAAE;IACR,CAACJ,SAAS,GAAGH,IAAI,CAACQ;EACpB,CAAC;EAEDC,QAAQ,EAAE;IACR,CAACN,SAAS,GAAIO,KAAK,IAAKV,IAAI,CAACW,MAAM,CAACD,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACG,QAAQ,CAAC,CAACC;EACpE,CAAC;EAEDC,KAAK,EAAE;IACL;IACAF,QAAQ,EAAE,GAAG;IACb;AACJ;AACA;AACA;AACA;AACA;IACIG,OAAO,CAACC,CAAC,EAAEC,EAAE,EAAE;MACb,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE;QACzB,OAAOhB,UAAU,CAACkB,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAED,EAAE,CAAC;MACxD;MAEA,IAAID,CAAC,GAAG,CAAC,IAAIA,CAAC,GAAG,GAAG,EAAE;QACpB,OAAOhB,UAAU,CAACkB,IAAI,CAAC,IAAI,EAAE,4BAA4B,EAAED,EAAE,CAAC;MAChE;MAEA,IAAI,CAACL,QAAQ,GAAGO,IAAI,CAACC,KAAK,CAACJ,CAAC,CAAC;MAE7B,IAAIf,aAAa,CAACgB,EAAE,CAAC,EAAE;QACrBA,EAAE,CAACC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;MAC3B;MAEA,OAAO,IAAI;IACb;EACF;AACF,CAAC,CAAC"}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { DecoderFn, EncoderFn, ImageCallback } from "@jimp/core";
|
||||
|
||||
interface JpegClass {
|
||||
_quality: number;
|
||||
quality: (n: number, cb?: ImageCallback<this>) => this;
|
||||
}
|
||||
|
||||
interface Jpeg {
|
||||
mime: { "image/jpeg": string[] };
|
||||
|
||||
constants: {
|
||||
MIME_JPEG: "image/jpeg";
|
||||
};
|
||||
|
||||
encoders: {
|
||||
"image/jpeg": EncoderFn;
|
||||
};
|
||||
|
||||
decoders: {
|
||||
"image/jpeg": DecoderFn;
|
||||
};
|
||||
|
||||
class: JpegClass;
|
||||
}
|
||||
|
||||
export default function (): Jpeg;
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@jimp/jpeg",
|
||||
"version": "0.22.12",
|
||||
"description": "Default Jimp jpeg encoder/decoder.",
|
||||
"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",
|
||||
"jpeg-js": "^0.4.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.22.12",
|
||||
"@jimp/test-utils": "^0.22.12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "a4a8d6364bbf97629749e196f3b0a4c94c9a7abc"
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import JPEG from "jpeg-js";
|
||||
import { throwError, isNodePattern } from "@jimp/utils";
|
||||
|
||||
const MIME_TYPE = "image/jpeg";
|
||||
|
||||
export default () => ({
|
||||
mime: { [MIME_TYPE]: ["jpeg", "jpg", "jpe"] },
|
||||
|
||||
constants: {
|
||||
MIME_JPEG: MIME_TYPE,
|
||||
},
|
||||
|
||||
decoders: {
|
||||
[MIME_TYPE]: JPEG.decode,
|
||||
},
|
||||
|
||||
encoders: {
|
||||
[MIME_TYPE]: (image) => JPEG.encode(image.bitmap, image._quality).data,
|
||||
},
|
||||
|
||||
class: {
|
||||
// The quality to be used when saving JPEG images
|
||||
_quality: 100,
|
||||
/**
|
||||
* Sets the quality of the image when saving as JPEG format (default is 100)
|
||||
* @param {number} n The quality to use 0-100
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
quality(n, cb) {
|
||||
if (typeof n !== "number") {
|
||||
return throwError.call(this, "n must be a number", cb);
|
||||
}
|
||||
|
||||
if (n < 0 || n > 100) {
|
||||
return throwError.call(this, "n must be a number 0 - 100", cb);
|
||||
}
|
||||
|
||||
this._quality = Math.round(n);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
},
|
||||
});
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
+42
@@ -0,0 +1,42 @@
|
||||
import { Jimp, getTestDir } from "@jimp/test-utils";
|
||||
import configure from "@jimp/custom";
|
||||
import expect from "@storybook/expect";
|
||||
|
||||
import jpeg from "../src";
|
||||
|
||||
const jimp = configure({ types: [jpeg] }, Jimp);
|
||||
|
||||
describe("JPEG", () => {
|
||||
const imagesDir = getTestDir(__dirname) + "/images";
|
||||
|
||||
it("load JPG", async () => {
|
||||
const image = await jimp.read(imagesDir + "/cops.jpg");
|
||||
|
||||
expect(image.getPixelColor(10, 10)).toBe(0x3f4a02ff);
|
||||
expect(image.getPixelColor(220, 190)).toBe(0x5d94b6ff);
|
||||
expect(image.getPixelColor(350, 130)).toBe(0xdf7944ff);
|
||||
});
|
||||
|
||||
it("load JPG with fill bytes", async () => {
|
||||
const image = await jimp.read(imagesDir + "/fillbytes.jpg");
|
||||
|
||||
expect(image.getPixelColor(10, 10)).toBe(0xaeb8c3ff);
|
||||
expect(image.getPixelColor(220, 190)).toBe(0x262b21ff);
|
||||
expect(image.getPixelColor(350, 130)).toBe(0x4e5d30ff);
|
||||
});
|
||||
|
||||
it("export JPG", async () => {
|
||||
const image = await jimp.read({
|
||||
width: 3,
|
||||
height: 3,
|
||||
data: [
|
||||
0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff,
|
||||
0xff00ffff, 0x8000ffff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
image.quality(50);
|
||||
const buffer = await image.getBufferAsync("image/jpeg");
|
||||
|
||||
expect(buffer.toString()).toMatch(/^.{3,9}JFIF\u0000/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user