image-js 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/image-js.esm.js +25 -14
- package/dist/image-js.esm.js.map +1 -1
- package/dist/image-js.esm.min.js +2 -2
- package/dist/image-js.esm.min.js.map +1 -1
- package/dist/image-js.umd.js +25 -14
- package/dist/image-js.umd.js.map +1 -1
- package/dist/image-js.umd.min.js +2 -2
- package/dist/image-js.umd.min.js.map +1 -1
- package/lib/load/decodePng.d.ts.map +1 -1
- package/lib/load/decodePng.js +26 -15
- package/lib/load/decodePng.js.map +1 -1
- package/package.json +8 -5
- package/src/load/decodePng.ts +25 -17
package/dist/image-js.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* image-js v1.6.
|
|
2
|
+
* image-js v1.6.1
|
|
3
3
|
* Image processing and manipulation in JavaScript
|
|
4
4
|
* https://github.com/image-js/image-js#readme
|
|
5
5
|
*
|
|
@@ -26356,18 +26356,7 @@ function decodePng(buffer) {
|
|
|
26356
26356
|
default:
|
|
26357
26357
|
throw new RangeError(`invalid number of channels: ${png.channels}`);
|
|
26358
26358
|
}
|
|
26359
|
-
|
|
26360
|
-
if (png.resolution) {
|
|
26361
|
-
resolution = png.resolution.unit === 1 ? /*If the resolution unit is meters*/{
|
|
26362
|
-
x: png.resolution.x,
|
|
26363
|
-
y: png.resolution.y,
|
|
26364
|
-
unit: 'meter'
|
|
26365
|
-
} : /*If resolution unit is unknown */{
|
|
26366
|
-
x: png.resolution.x,
|
|
26367
|
-
y: png.resolution.y,
|
|
26368
|
-
unit: 'unknown'
|
|
26369
|
-
};
|
|
26370
|
-
}
|
|
26359
|
+
const resolution = getResolution(png);
|
|
26371
26360
|
return new Image(png.width, png.height, {
|
|
26372
26361
|
colorModel,
|
|
26373
26362
|
bitDepth,
|
|
@@ -26399,9 +26388,11 @@ function loadPalettePng(png) {
|
|
|
26399
26388
|
data[dataIndex++] = paletteChannel;
|
|
26400
26389
|
}
|
|
26401
26390
|
}
|
|
26391
|
+
const resolution = getResolution(png);
|
|
26402
26392
|
return new Image(png.width, png.height, {
|
|
26403
26393
|
data,
|
|
26404
|
-
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB'
|
|
26394
|
+
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB',
|
|
26395
|
+
resolution
|
|
26405
26396
|
});
|
|
26406
26397
|
}
|
|
26407
26398
|
function decodeBinary(png) {
|
|
@@ -26421,6 +26412,26 @@ function decodeBinary(png) {
|
|
|
26421
26412
|
}
|
|
26422
26413
|
return result;
|
|
26423
26414
|
}
|
|
26415
|
+
/**
|
|
26416
|
+
* Gets image's resolution from its parsed data.
|
|
26417
|
+
* @param png - Parsed .png image.
|
|
26418
|
+
* @returns Object with resolution data if exists.
|
|
26419
|
+
*/
|
|
26420
|
+
function getResolution(png) {
|
|
26421
|
+
if (png.resolution) {
|
|
26422
|
+
return png.resolution.unit === 1 ? /*If the resolution unit is meters*/{
|
|
26423
|
+
x: png.resolution.x,
|
|
26424
|
+
y: png.resolution.y,
|
|
26425
|
+
unit: 'meter'
|
|
26426
|
+
} : /*If resolution unit is unknown */{
|
|
26427
|
+
x: png.resolution.x,
|
|
26428
|
+
y: png.resolution.y,
|
|
26429
|
+
unit: 'unknown'
|
|
26430
|
+
};
|
|
26431
|
+
} else {
|
|
26432
|
+
return undefined;
|
|
26433
|
+
}
|
|
26434
|
+
}
|
|
26424
26435
|
|
|
26425
26436
|
/**
|
|
26426
26437
|
* Decode a TIFF. See the tiff module.
|