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.umd.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
|
*
|
|
@@ -26361,18 +26361,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
26361
26361
|
default:
|
|
26362
26362
|
throw new RangeError(`invalid number of channels: ${png.channels}`);
|
|
26363
26363
|
}
|
|
26364
|
-
|
|
26365
|
-
if (png.resolution) {
|
|
26366
|
-
resolution = png.resolution.unit === 1 ? /*If the resolution unit is meters*/{
|
|
26367
|
-
x: png.resolution.x,
|
|
26368
|
-
y: png.resolution.y,
|
|
26369
|
-
unit: 'meter'
|
|
26370
|
-
} : /*If resolution unit is unknown */{
|
|
26371
|
-
x: png.resolution.x,
|
|
26372
|
-
y: png.resolution.y,
|
|
26373
|
-
unit: 'unknown'
|
|
26374
|
-
};
|
|
26375
|
-
}
|
|
26364
|
+
const resolution = getResolution(png);
|
|
26376
26365
|
return new Image(png.width, png.height, {
|
|
26377
26366
|
colorModel,
|
|
26378
26367
|
bitDepth,
|
|
@@ -26404,9 +26393,11 @@ ${indent}columns: ${matrix.columns}
|
|
|
26404
26393
|
data[dataIndex++] = paletteChannel;
|
|
26405
26394
|
}
|
|
26406
26395
|
}
|
|
26396
|
+
const resolution = getResolution(png);
|
|
26407
26397
|
return new Image(png.width, png.height, {
|
|
26408
26398
|
data,
|
|
26409
|
-
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB'
|
|
26399
|
+
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB',
|
|
26400
|
+
resolution
|
|
26410
26401
|
});
|
|
26411
26402
|
}
|
|
26412
26403
|
function decodeBinary(png) {
|
|
@@ -26426,6 +26417,26 @@ ${indent}columns: ${matrix.columns}
|
|
|
26426
26417
|
}
|
|
26427
26418
|
return result;
|
|
26428
26419
|
}
|
|
26420
|
+
/**
|
|
26421
|
+
* Gets image's resolution from its parsed data.
|
|
26422
|
+
* @param png - Parsed .png image.
|
|
26423
|
+
* @returns Object with resolution data if exists.
|
|
26424
|
+
*/
|
|
26425
|
+
function getResolution(png) {
|
|
26426
|
+
if (png.resolution) {
|
|
26427
|
+
return png.resolution.unit === 1 ? /*If the resolution unit is meters*/{
|
|
26428
|
+
x: png.resolution.x,
|
|
26429
|
+
y: png.resolution.y,
|
|
26430
|
+
unit: 'meter'
|
|
26431
|
+
} : /*If resolution unit is unknown */{
|
|
26432
|
+
x: png.resolution.x,
|
|
26433
|
+
y: png.resolution.y,
|
|
26434
|
+
unit: 'unknown'
|
|
26435
|
+
};
|
|
26436
|
+
} else {
|
|
26437
|
+
return undefined;
|
|
26438
|
+
}
|
|
26439
|
+
}
|
|
26429
26440
|
|
|
26430
26441
|
/**
|
|
26431
26442
|
* Decode a TIFF. See the tiff module.
|