Comparing version
/* eslint-env worker */ | ||
/* global Jimp */ | ||
importScripts('../lib/jimp.min.js'); | ||
importScripts("../lib/jimp.min.js"); | ||
self.addEventListener('message', e => { | ||
Jimp.read(e.data).then(lenna => { | ||
self.addEventListener("message", (e) => { | ||
Jimp.read(e.data).then((lenna) => { | ||
lenna | ||
@@ -9,0 +9,0 @@ .resize(256, Jimp.AUTO) // resize |
@@ -10,18 +10,21 @@ # Jimp ... in a browser | ||
<script> | ||
Jimp.read("lenna.png").then(function (lenna) { | ||
lenna.resize(256, 256) // resize | ||
.quality(60) // set JPEG quality | ||
.greyscale() // set greyscale | ||
.getBase64(Jimp.MIME_JPEG, function (err, src) { | ||
var img = document.createElement("img"); | ||
img.setAttribute("src", src); | ||
document.body.appendChild(img); | ||
}); | ||
}).catch(function (err) { | ||
console.error(err); | ||
}); | ||
Jimp.read("lenna.png") | ||
.then(function (lenna) { | ||
lenna | ||
.resize(256, 256) // resize | ||
.quality(60) // set JPEG quality | ||
.greyscale() // set greyscale | ||
.getBase64(Jimp.MIME_JPEG, function (err, src) { | ||
var img = document.createElement("img"); | ||
img.setAttribute("src", src); | ||
document.body.appendChild(img); | ||
}); | ||
}) | ||
.catch(function (err) { | ||
console.error(err); | ||
}); | ||
</script> | ||
``` | ||
See the [main documentation](https://github.com/oliver-moran/jimp) for the full API documenatinon. | ||
See the [main documentation](https://github.com/jimp-dev/jimp) for the full API documenatinon. | ||
@@ -35,10 +38,10 @@ ## WebWorkers | ||
var worker = new Worker('jimp-worker.js'); | ||
worker.onmessage = function(e) { | ||
var worker = new Worker("jimp-worker.js"); | ||
worker.onmessage = function (e) { | ||
// append a new img element using the base 64 image | ||
var img = document.createElement('img'); | ||
img.setAttribute('src', e.data); | ||
var img = document.createElement("img"); | ||
img.setAttribute("src", e.data); | ||
document.body.appendChild(img); | ||
}; | ||
worker.postMessage('lenna.png'); // message the worker thread | ||
worker.postMessage("lenna.png"); // message the worker thread | ||
``` | ||
@@ -49,6 +52,6 @@ | ||
importScripts('jimp.min.js'); | ||
importScripts("jimp.min.js"); | ||
self.addEventListener('message', function(e) { | ||
Jimp.read(e.data).then(function(lenna) { | ||
self.addEventListener("message", function (e) { | ||
Jimp.read(e.data).then(function (lenna) { | ||
lenna | ||
@@ -58,3 +61,3 @@ .resize(256, 256) // resize | ||
.greyscale() // set greyscale | ||
.getBase64(Jimp.MIME_JPEG, function(err, src) { | ||
.getBase64(Jimp.MIME_JPEG, function (err, src) { | ||
self.postMessage(src); // message the main thread | ||
@@ -61,0 +64,0 @@ }); |
@@ -0,1 +1,22 @@ | ||
# v0.16.3 (Sat Feb 04 2023) | ||
#### 🐛 Bug Fix | ||
- Fix edgeHandling types [#1080](https://github.com/jimp-dev/jimp/pull/1080) ([@domdomegg](https://github.com/domdomegg)) | ||
- Readme: Fix measureText sample code [#1102](https://github.com/jimp-dev/jimp/pull/1102) ([@dkong](https://github.com/dkong) [@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### ⚠️ Pushed to `master` | ||
- try this ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- update linting ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 3 | ||
- Adam Jones ([@domdomegg](https://github.com/domdomegg)) | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Dara Kong ([@dkong](https://github.com/dkong)) | ||
--- | ||
# v0.15.0 (Fri Aug 07 2020) | ||
@@ -105,3 +126,3 @@ | ||
#### 🐛 Bug Fix | ||
#### 🐛 Bug Fix | ||
@@ -114,2 +135,2 @@ - `@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` | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn)) | ||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn)) |
{ | ||
"name": "jimp", | ||
"version": "0.16.1", | ||
"version": "0.16.13", | ||
"description": "An image processing library written entirely in JavaScript (i.e. zero external or native dependencies)", | ||
@@ -24,9 +24,3 @@ "main": "dist/index.js", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/oliver-moran/jimp.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/oliver-moran/jimp/issues" | ||
}, | ||
"repository": "jimp-dev/jimp", | ||
"scripts": { | ||
@@ -63,5 +57,5 @@ "test": "cross-env BABEL_ENV=test mocha --require @babel/register", | ||
"@babel/runtime": "^7.7.2", | ||
"@jimp/custom": "^0.16.1", | ||
"@jimp/plugins": "^0.16.1", | ||
"@jimp/types": "^0.16.1", | ||
"@jimp/custom": "^0.16.13", | ||
"@jimp/plugins": "^0.16.13", | ||
"@jimp/types": "^0.16.13", | ||
"regenerator-runtime": "^0.13.3" | ||
@@ -76,3 +70,3 @@ }, | ||
"@babel/register": "^7.7.0", | ||
"@jimp/test-utils": "^0.16.1", | ||
"@jimp/test-utils": "^0.16.13", | ||
"babel-eslint": "^10.0.3", | ||
@@ -88,3 +82,2 @@ "babel-plugin-add-module-exports": "^1.0.2", | ||
"eslint": "^6.4.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"express": "^4.17.1", | ||
@@ -101,10 +94,7 @@ "husky": "^3.0.5", | ||
"nyc": "^14.1.1", | ||
"prettier": "^1.18.2", | ||
"source-map-support": "^0.5.13", | ||
"tfilter": "^1.0.1", | ||
"uglify-js": "^3.6.0", | ||
"watchify": "^3.11.1", | ||
"xo": "^0.24.0" | ||
"watchify": "^3.11.1" | ||
}, | ||
"xo": false, | ||
"nyc": { | ||
@@ -124,3 +114,3 @@ "sourceMap": false, | ||
}, | ||
"gitHead": "909f06eac36ef5ba36ebb1e0853fd006c4da3560" | ||
"gitHead": "9eec86086634329a072901dca3a800b850548572" | ||
} |
133
README.md
@@ -29,6 +29,6 @@ <div align="center"> | ||
```js | ||
var Jimp = require('jimp'); | ||
var Jimp = require("jimp"); | ||
// open a file called "lenna.png" | ||
Jimp.read('lenna.png', (err, lenna) => { | ||
Jimp.read("lenna.png", (err, lenna) => { | ||
if (err) throw err; | ||
@@ -39,3 +39,3 @@ lenna | ||
.greyscale() // set greyscale | ||
.write('lena-small-bw.jpg'); // save | ||
.write("lena-small-bw.jpg"); // save | ||
}); | ||
@@ -47,4 +47,4 @@ ``` | ||
```js | ||
Jimp.read('lenna.png') | ||
.then(lenna => { | ||
Jimp.read("lenna.png") | ||
.then((lenna) => { | ||
return lenna | ||
@@ -54,5 +54,5 @@ .resize(256, 256) // resize | ||
.greyscale() // set greyscale | ||
.write('lena-small-bw.jpg'); // save | ||
.write("lena-small-bw.jpg"); // save | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
console.error(err); | ||
@@ -67,3 +67,3 @@ }); | ||
```ts | ||
import Jimp from 'jimp'; | ||
import Jimp from "jimp"; | ||
``` | ||
@@ -82,3 +82,3 @@ | ||
```js | ||
import Jimp from 'jimp/es'; | ||
import Jimp from "jimp/es"; | ||
``` | ||
@@ -106,15 +106,15 @@ | ||
```js | ||
Jimp.read('./path/to/image.jpg') | ||
.then(image => { | ||
Jimp.read("./path/to/image.jpg") | ||
.then((image) => { | ||
// Do stuff with the image. | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
// Handle an exception. | ||
}); | ||
Jimp.read('http://www.example.com/path/to/lenna.jpg') | ||
.then(image => { | ||
Jimp.read("http://www.example.com/path/to/lenna.jpg") | ||
.then((image) => { | ||
// Do stuff with the image. | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
// Handle an exception. | ||
@@ -124,6 +124,6 @@ }); | ||
Jimp.read(jimpInstance) | ||
.then(image => { | ||
.then((image) => { | ||
// Do stuff with the image. | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
// Handle an exception. | ||
@@ -133,6 +133,6 @@ }); | ||
Jimp.read(buffer) | ||
.then(image => { | ||
.then((image) => { | ||
// Do stuff with the image. | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
// Handle an exception. | ||
@@ -174,5 +174,5 @@ }); | ||
Jimp.appendConstructorOption( | ||
'Name of Option', | ||
args => arg.hasSomeCustomThing, | ||
function(resolve, reject, args) { | ||
"Name of Option", | ||
(args) => arg.hasSomeCustomThing, | ||
function (resolve, reject, args) { | ||
this.bitmap = customParser(args); | ||
@@ -189,13 +189,7 @@ resolve(); | ||
```js | ||
Jimp.appendConstructorOption('Custom Url', options => options.url, function( | ||
resolve, | ||
reject, | ||
options | ||
) { | ||
phin(options, (err, res) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
this.parseBitmap(res.body, options.url, err => { | ||
Jimp.appendConstructorOption( | ||
"Custom Url", | ||
(options) => options.url, | ||
function (resolve, reject, options) { | ||
phin(options, (err, res) => { | ||
if (err) { | ||
@@ -205,6 +199,12 @@ return reject(err); | ||
resolve(); | ||
this.parseBitmap(res.body, options.url, (err) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
``` | ||
@@ -373,3 +373,3 @@ | ||
opacitySource: 0.5, | ||
opacityDest: 0.9 | ||
opacityDest: 0.9, | ||
}); | ||
@@ -383,3 +383,3 @@ ``` | ||
```js | ||
Jimp.loadFont(pathOrURL).then(font => { | ||
Jimp.loadFont(pathOrURL).then((font) => { | ||
// load font from .fnt file | ||
@@ -394,3 +394,3 @@ image.print(font, x, y, message); // print a message on an image. message can be a any type | ||
```js | ||
Jimp.loadFont(pathOrURL).then(font => { | ||
Jimp.loadFont(pathOrURL).then((font) => { | ||
image.print( | ||
@@ -401,5 +401,5 @@ font, | ||
{ | ||
text: 'Hello world!', | ||
text: "Hello world!", | ||
alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER, | ||
alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE | ||
alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE, | ||
}, | ||
@@ -438,4 +438,4 @@ maxWidth, | ||
```js | ||
Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => { | ||
image.print(font, 10, 10, 'Hello world!'); | ||
Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then((font) => { | ||
image.print(font, 10, 10, "Hello world!"); | ||
}); | ||
@@ -449,4 +449,8 @@ ``` | ||
```js | ||
Jimp.measureText(Jimp.FONT_SANS_32_BLACK, 'Some string'); // width of text | ||
Jimp.measureTextHeight(Jimp.FONT_SANS_32_BLACK, 'Some string', 100); // height of text | ||
Jimp.measureText(await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK), "Some string"); // width of text | ||
Jimp.measureTextHeight( | ||
await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK), | ||
"Some string", | ||
100 | ||
); // height of text | ||
``` | ||
@@ -459,3 +463,3 @@ | ||
```js | ||
Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => { | ||
Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then((font) => { | ||
image.print( | ||
@@ -465,6 +469,6 @@ font, | ||
10, | ||
'Hello world that wraps!', | ||
"Hello world that wraps!", | ||
50, | ||
(err, image, { x, y }) => { | ||
image.print(font, x, y + 20, 'More text on another line', 50); | ||
image.print(font, x, y + 20, "More text on another line", 50); | ||
} | ||
@@ -495,5 +499,5 @@ ); | ||
```js | ||
var file = 'new_name.' + image.getExtension(); | ||
var file = "new_name." + image.getExtension(); | ||
//or | ||
var file = 'new_name'; // with no extension | ||
var file = "new_name"; // with no extension | ||
image.write(file); | ||
@@ -566,5 +570,5 @@ ``` | ||
image.color([ | ||
{ apply: 'hue', params: [-90] }, | ||
{ apply: 'lighten', params: [50] }, | ||
{ apply: 'xor', params: ['#06D'] } | ||
{ apply: "hue", params: [-90] }, | ||
{ apply: "lighten", params: [50] }, | ||
{ apply: "xor", params: ["#06D"] }, | ||
]); | ||
@@ -600,3 +604,7 @@ ``` | ||
```js | ||
image.convolute([[-2, -1, 0], [-1, 1, 1], [0, 1, 2]]); | ||
image.convolute([ | ||
[-2, -1, 0], | ||
[-1, 1, 1], | ||
[0, 1, 2], | ||
]); | ||
``` | ||
@@ -625,3 +633,3 @@ | ||
```js | ||
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) { | ||
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) { | ||
// x, y is the position of this pixel on the image | ||
@@ -644,3 +652,3 @@ // idx is the position start position of this rgba tuple in the bitmap Buffer | ||
```js | ||
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) { | ||
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) { | ||
// do your stuff.. | ||
@@ -721,3 +729,3 @@ | ||
```js | ||
new Jimp(256, 256, '#FF00FF', (err, image) => { | ||
new Jimp(256, 256, "#FF00FF", (err, image) => { | ||
// this image is 256 x 256, every pixel is set to #FF00FF | ||
@@ -795,7 +803,4 @@ }); | ||
```js | ||
Jimp.read('lenna.png').then(image => { | ||
image | ||
.greyscale() | ||
.scale(0.5) | ||
.write('lena-half-bw.png'); | ||
Jimp.read("lenna.png").then((image) => { | ||
image.greyscale().scale(0.5).write("lena-half-bw.png"); | ||
}); | ||
@@ -807,6 +812,6 @@ ``` | ||
```js | ||
Jimp.read('lenna.png').then(image => { | ||
Jimp.read("lenna.png").then((image) => { | ||
image.greyscale((err, image) => { | ||
image.scale(0.5, (err, image) => { | ||
image.write('lena-half-bw.png'); | ||
image.write("lena-half-bw.png"); | ||
}); | ||
@@ -813,0 +818,0 @@ }); |
// TypeScript Version: 2.8 | ||
declare const DepreciatedJimp: DepreciatedJimp; | ||
@@ -13,8 +12,8 @@ | ||
// Constructors | ||
new(path: string, cb?: ImageCallback): this; | ||
new(urlOptions: URLOptions, cb?: ImageCallback): this; | ||
new(image: DepreciatedJimp, cb?: ImageCallback): this; | ||
new(data: Buffer | Bitmap, cb?: ImageCallback): this; | ||
new(w: number, h: number, cb?: ImageCallback): this; | ||
new( | ||
new (path: string, cb?: ImageCallback): this; | ||
new (urlOptions: URLOptions, cb?: ImageCallback): this; | ||
new (image: DepreciatedJimp, cb?: ImageCallback): this; | ||
new (data: Buffer | Bitmap, cb?: ImageCallback): this; | ||
new (w: number, h: number, cb?: ImageCallback): this; | ||
new ( | ||
w: number, | ||
@@ -26,3 +25,3 @@ h: number, | ||
// For custom constructors when using Jimp.appendConstructorOption | ||
new(...args: any[]): this; | ||
new (...args: any[]): this; | ||
prototype: this; | ||
@@ -34,9 +33,9 @@ | ||
// supported mime types | ||
MIME_PNG: 'image/png'; | ||
MIME_TIFF: 'image/tiff'; | ||
MIME_JPEG: 'image/jpeg'; | ||
MIME_JGD: 'image/jgd'; | ||
MIME_BMP: 'image/bmp'; | ||
MIME_X_MS_BMP: 'image/x-ms-bmp'; | ||
MIME_GIF: 'image/gif'; | ||
MIME_PNG: "image/png"; | ||
MIME_TIFF: "image/tiff"; | ||
MIME_JPEG: "image/jpeg"; | ||
MIME_JGD: "image/jgd"; | ||
MIME_BMP: "image/bmp"; | ||
MIME_X_MS_BMP: "image/x-ms-bmp"; | ||
MIME_GIF: "image/gif"; | ||
// PNG filter types | ||
@@ -51,7 +50,7 @@ PNG_FILTER_AUTO: -1; | ||
// resize methods | ||
RESIZE_NEAREST_NEIGHBOR: 'nearestNeighbor'; | ||
RESIZE_BILINEAR: 'bilinearInterpolation'; | ||
RESIZE_BICUBIC: 'bicubicInterpolation'; | ||
RESIZE_HERMITE: 'hermiteInterpolation'; | ||
RESIZE_BEZIER: 'bezierInterpolation'; | ||
RESIZE_NEAREST_NEIGHBOR: "nearestNeighbor"; | ||
RESIZE_BILINEAR: "bilinearInterpolation"; | ||
RESIZE_BICUBIC: "bicubicInterpolation"; | ||
RESIZE_HERMITE: "hermiteInterpolation"; | ||
RESIZE_BEZIER: "bezierInterpolation"; | ||
@@ -154,3 +153,3 @@ // blend modes | ||
y: number, | ||
edgeHandling: string, | ||
edgeHandling: number, | ||
cb?: GenericCallback<number, any, this> | ||
@@ -195,3 +194,8 @@ ): number; | ||
h: number | ||
): IterableIterator<{ x: number; y: number; idx: number; image: DepreciatedJimp }>; | ||
): IterableIterator<{ | ||
x: number; | ||
y: number; | ||
idx: number; | ||
image: DepreciatedJimp; | ||
}>; | ||
crop(x: number, y: number, w: number, h: number, cb?: ImageCallback): this; | ||
@@ -218,3 +222,3 @@ cropQuiet( | ||
kernel: number[][], | ||
edgeHandling: string, | ||
edgeHandling: number, | ||
cb?: ImageCallback | ||
@@ -374,3 +378,4 @@ ): this; | ||
cb?: ImageCallback | ||
): Promise<this>; create(path: string): Promise<this>; | ||
): Promise<this>; | ||
create(path: string): Promise<this>; | ||
create(image: this): Promise<this>; | ||
@@ -453,10 +458,10 @@ create(data: Buffer): Promise<this>; | ||
type ColorActionName = | ||
| 'mix' | ||
| 'tint' | ||
| 'shade' | ||
| 'xor' | ||
| 'red' | ||
| 'green' | ||
| 'blue' | ||
| 'hue'; | ||
| "mix" | ||
| "tint" | ||
| "shade" | ||
| "xor" | ||
| "red" | ||
| "green" | ||
| "blue" | ||
| "hue"; | ||
@@ -474,28 +479,30 @@ type ColorAction = { | ||
type ChangeName = 'background' | 'scan' | 'crop'; | ||
type ChangeName = "background" | "scan" | "crop"; | ||
type ListenableName = | ||
| 'any' | ||
| 'initialized' | ||
| 'before-change' | ||
| 'changed' | ||
| 'before-clone' | ||
| 'cloned' | ||
| "any" | ||
| "initialized" | ||
| "before-change" | ||
| "changed" | ||
| "before-clone" | ||
| "cloned" | ||
| ChangeName; | ||
type ListenerData<T extends ListenableName> = T extends 'any' | ||
type ListenerData<T extends ListenableName> = T extends "any" | ||
? any | ||
: T extends ChangeName | ||
? { | ||
eventName: 'before-change' | 'changed'; | ||
? { | ||
eventName: "before-change" | "changed"; | ||
methodName: T; | ||
[key: string]: any; | ||
} | ||
: { | ||
: { | ||
eventName: T; | ||
methodName: T extends 'initialized' | ||
? 'constructor' | ||
: T extends 'before-change' | 'changed' | ||
? ChangeName | ||
: T extends 'before-clone' | 'cloned' ? 'clone' : any; | ||
methodName: T extends "initialized" | ||
? "constructor" | ||
: T extends "before-change" | "changed" | ||
? ChangeName | ||
: T extends "before-clone" | "cloned" | ||
? "clone" | ||
: any; | ||
}; | ||
@@ -506,6 +513,6 @@ | ||
| { | ||
text: string; | ||
alignmentX: number; | ||
alignmentY: number; | ||
}; | ||
text: string; | ||
alignmentX: number; | ||
alignmentY: number; | ||
}; | ||
@@ -512,0 +519,0 @@ type URLOptions = { |
@@ -1,7 +0,7 @@ | ||
import * as Jimp from 'jimp'; | ||
import * as Jimp from "jimp"; | ||
const jimpInst: Jimp = new Jimp('test'); | ||
const jimpInst: Jimp = new Jimp("test"); | ||
// Main Jimp export should already have all of these already applied | ||
jimpInst.read('Test'); | ||
jimpInst.read("Test"); | ||
jimpInst.displace(jimpInst, 2); | ||
@@ -19,3 +19,3 @@ jimpInst.resize(40, 40); | ||
// Main Jimp export should already have all of these already applied | ||
Jimp.read('Test'); | ||
Jimp.read("Test"); | ||
Jimp.displace(Jimp, 2); | ||
@@ -33,4 +33,4 @@ Jimp.shadow((err, val, coords) => {}); | ||
test('can clone properly', async () => { | ||
const baseImage = await Jimp.read('filename'); | ||
test("can clone properly", async () => { | ||
const baseImage = await Jimp.read("filename"); | ||
const cloneBaseImage = baseImage.clone(); | ||
@@ -41,8 +41,8 @@ | ||
test('can handle `this` returns on the core type properly', () => { | ||
test("can handle `this` returns on the core type properly", () => { | ||
// $ExpectType -1 | ||
cloneBaseImage.diff(jimpInst, jimpInst).image.PNG_FILTER_AUTO | ||
cloneBaseImage.diff(jimpInst, jimpInst).image.PNG_FILTER_AUTO; | ||
}); | ||
test('can handle `this` returns properly', () => { | ||
test("can handle `this` returns properly", () => { | ||
cloneBaseImage | ||
@@ -52,12 +52,11 @@ .resize(1, 1) | ||
.mask(cloneBaseImage, 2, 2) | ||
.print('a' as any, 2, 2, 'a' as any) | ||
.print("a" as any, 2, 2, "a" as any) | ||
.resize(1, 1) | ||
.quality(1) | ||
.deflateLevel(2) | ||
.PNG_FILTER_AUTO; | ||
.deflateLevel(2).PNG_FILTER_AUTO; | ||
}); | ||
test('can handle imageCallbacks `this` properly', () => { | ||
test("can handle imageCallbacks `this` properly", () => { | ||
cloneBaseImage.rgba(false, (_, jimpCBIn) => { | ||
jimpCBIn.read('Test'); | ||
jimpCBIn.read("Test"); | ||
jimpCBIn.displace(jimpInst, 2); | ||
@@ -73,11 +72,11 @@ jimpCBIn.resize(40, 40); | ||
jimpCBIn.func(); | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
test('Can handle callback with constructor', () => { | ||
test("Can handle callback with constructor", () => { | ||
const myBmpBuffer: Buffer = {} as any; | ||
Jimp.read(myBmpBuffer, (err, cbJimpInst) => { | ||
cbJimpInst.read('Test'); | ||
cbJimpInst.read("Test"); | ||
cbJimpInst.displace(jimpInst, 2); | ||
@@ -94,9 +93,9 @@ cbJimpInst.resize(40, 40); | ||
}); | ||
}) | ||
}); | ||
test('Can handle appendConstructorOption', () => { | ||
test("Can handle appendConstructorOption", () => { | ||
Jimp.appendConstructorOption( | ||
'Name of Option', | ||
args => args.hasSomeCustomThing, | ||
function(resolve, reject, args) { | ||
"Name of Option", | ||
(args) => args.hasSomeCustomThing, | ||
function (resolve, reject, args) { | ||
// $ExpectError | ||
@@ -103,0 +102,0 @@ this.bitmap = 3; |
@@ -18,6 +18,6 @@ /** | ||
GetPluginDecoders, | ||
JimpConstructors | ||
} from '@jimp/core'; | ||
import typeFn from '@jimp/types'; | ||
import pluginFn from '@jimp/plugins'; | ||
JimpConstructors, | ||
} from "@jimp/core"; | ||
import typeFn from "@jimp/types"; | ||
import pluginFn from "@jimp/plugins"; | ||
@@ -45,8 +45,9 @@ type Types = ReturnType<typeof typeFn>; | ||
declare const Jimp: JimpConstructors & IntersectedPluginConsts & { | ||
prototype: Jimp; | ||
encoders: IntersectedPluginEncoders; | ||
decoders: IntersectedPluginDecoders; | ||
}; | ||
declare const Jimp: JimpConstructors & | ||
IntersectedPluginConsts & { | ||
prototype: Jimp; | ||
encoders: IntersectedPluginEncoders; | ||
decoders: IntersectedPluginDecoders; | ||
}; | ||
export = Jimp; |
@@ -1,8 +0,8 @@ | ||
import * as Jimp from 'jimp'; | ||
import * as Jimp from "jimp"; | ||
const jimpInst: Jimp = new Jimp('test'); | ||
const jimpInst: Jimp = new Jimp("test"); | ||
// Main Jimp export should already have all of these already applied | ||
// $ExpectError | ||
jimpInst.read('Test'); | ||
jimpInst.read("Test"); | ||
jimpInst.displace(jimpInst, 2); | ||
@@ -12,4 +12,4 @@ jimpInst.resize(40, 40); | ||
jimpInst.shadow((err, val, coords) => {}); | ||
jimpInst.fishEye({r: 12}); | ||
jimpInst.circle({radius: 12, x: 12, y: 12}); | ||
jimpInst.fishEye({ r: 12 }); | ||
jimpInst.circle({ radius: 12, x: 12, y: 12 }); | ||
// $ExpectError | ||
@@ -25,3 +25,3 @@ jimpInst.PNG_FILTER_NONE; | ||
// Main Jimp export should already have all of these already applied | ||
Jimp.read('Test'); | ||
Jimp.read("Test"); | ||
@@ -37,4 +37,4 @@ // $ExpectType 0 | ||
test('can clone properly', async () => { | ||
const baseImage = await Jimp.read('filename'); | ||
test("can clone properly", async () => { | ||
const baseImage = await Jimp.read("filename"); | ||
const cloneBaseImage = baseImage.clone(); | ||
@@ -45,8 +45,8 @@ | ||
test('can handle `this` returns on the core type properly', () => { | ||
test("can handle `this` returns on the core type properly", () => { | ||
// $ExpectType number | ||
cloneBaseImage.posterize(3)._quality | ||
cloneBaseImage.posterize(3)._quality; | ||
}); | ||
test('can handle `this` returns properly', () => { | ||
test("can handle `this` returns properly", () => { | ||
cloneBaseImage | ||
@@ -56,13 +56,12 @@ .resize(1, 1) | ||
.mask(cloneBaseImage, 2, 2) | ||
.print('a' as any, 2, 2, 'a' as any) | ||
.print("a" as any, 2, 2, "a" as any) | ||
.resize(1, 1) | ||
.quality(1) | ||
.deflateLevel(2) | ||
._filterType; | ||
.deflateLevel(2)._filterType; | ||
}); | ||
test('can handle imageCallbacks `this` properly', () => { | ||
test("can handle imageCallbacks `this` properly", () => { | ||
cloneBaseImage.rgba(false, (_, jimpCBIn) => { | ||
// $ExpectError | ||
jimpCBIn.read('Test'); | ||
jimpCBIn.read("Test"); | ||
jimpCBIn.displace(jimpInst, 2); | ||
@@ -78,7 +77,7 @@ jimpCBIn.resize(40, 40); | ||
jimpCBIn.func(); | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
test('Can handle callback with constructor', () => { | ||
test("Can handle callback with constructor", () => { | ||
const myBmpBuffer: Buffer = {} as any; | ||
@@ -88,3 +87,3 @@ | ||
// $ExpectError | ||
cbJimpInst.read('Test'); | ||
cbJimpInst.read("Test"); | ||
cbJimpInst.displace(jimpInst, 2); | ||
@@ -91,0 +90,0 @@ cbJimpInst.resize(40, 40); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
32
-8.57%795
0.63%1508185
-50.77%48
-9.43%834
-98.02%1
Infinity%1
Infinity%Updated
Updated
Updated