ag-psd 34.0.0 → 34.1.0
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/CHANGELOG.md +6 -0
- package/README.md +11 -0
- package/README_PSD.md +1 -1
- package/TODO.md +0 -14
- package/dist/additionalInfo.js +14 -3
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +137 -18
- package/dist/imageResources.d.ts +2 -0
- package/dist/imageResources.js +29 -4
- package/dist/imageResources.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/psd.d.ts +27 -20
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.d.ts +5 -1
- package/dist/psdReader.js +89 -10
- package/dist/psdReader.js.map +1 -1
- package/dist-es/additionalInfo.js +14 -3
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/imageResources.d.ts +2 -0
- package/dist-es/imageResources.js +29 -4
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/index.d.ts +2 -2
- package/dist-es/index.js +5 -1
- package/dist-es/index.js.map +1 -1
- package/dist-es/psd.d.ts +27 -20
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.d.ts +5 -1
- package/dist-es/psdReader.js +89 -10
- package/dist-es/psdReader.js.map +1 -1
- package/fuzz.js +808 -0
- package/package.json +1 -1
- package/src/additionalInfo.ts +15 -4
- package/src/imageResources.ts +31 -3
- package/src/index.ts +2 -2
- package/src/psd.ts +30 -20
- package/src/psdReader.ts +89 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v34.1.0
|
|
4
|
+
- Added `imageResourcesWhitelist` read option for reading only listed image resources (other image resources are skipped without decoding)
|
|
5
|
+
- Added `getFilterEffectsMaskImageData`, `getFilterEffectsMaskExtraImageData`, `getFilterEffectsMaskCanvas` and `getFilterEffectsMaskExtraCanvas` functions for decoding image data of `filterEffectsMasks`
|
|
6
|
+
- Added `FilterEffectsMask` type and `colorMode` field to `filterEffectsMasks` items (color mode of the document, used for decoding image data)
|
|
7
|
+
- Fixed reading zip compressed image data with invalid checksum throwing an error (data is decoded ignoring the checksum, unless `strict` option is set)
|
|
8
|
+
|
|
3
9
|
## v34.0.0
|
|
4
10
|
- **BREAKING CHANGE:** Documents are now written in their `colorMode` and `bitsPerChannel` ("Bitmap", "Grayscale", "Indexed", "RGB" and "CMYK" color modes, 16 and 32 bits per channel for "RGB" and "Grayscale" and 16 bits for "CMYK"), previously documents were always written as 8 bit RGB documents (set `colorMode` to `ColorMode.RGB` and `bitsPerChannel` to `8` before writing to keep the previous behavior). Image data is converted from RGB data to the color mode and bit depth of the document, 16 and 32 bit layers are written in `Lr16` / `Lr32` sections using zip compression with prediction, 32 bit documents include HDR toning settings required by Photoshop
|
|
5
11
|
- **BREAKING CHANGE:** Book (Pantone) colors in descriptors are now read with their color values (previously they were read as black) and `book` field with name of the color book and the color
|
package/README.md
CHANGED
|
@@ -51,6 +51,12 @@ export function getLayerRealMaskCanvas(layer: Layer): Canvas | undefined;
|
|
|
51
51
|
export function getCompositeImageData(psd: Psd): PixelData | undefined;
|
|
52
52
|
export function getCompositeCanvas(psd: Psd): Canvas | undefined;
|
|
53
53
|
|
|
54
|
+
// functions for reading image data stored in `filterEffectsMasks` field
|
|
55
|
+
export function getFilterEffectsMaskImageData(mask: FilterEffectsMask): PixelData | undefined;
|
|
56
|
+
export function getFilterEffectsMaskExtraImageData(mask: FilterEffectsMask): PixelData | undefined;
|
|
57
|
+
export function getFilterEffectsMaskCanvas(mask: FilterEffectsMask): Canvas | undefined;
|
|
58
|
+
export function getFilterEffectsMaskExtraCanvas(mask: FilterEffectsMask): Canvas | undefined;
|
|
59
|
+
|
|
54
60
|
// Writing
|
|
55
61
|
|
|
56
62
|
// write PSD to ArrayBuffer
|
|
@@ -306,6 +312,11 @@ interface ReadOptions {
|
|
|
306
312
|
/** Loads thumbnail raw data instead of decoding it's content into canvas.
|
|
307
313
|
* `thumnailRaw` field is used instead of `thumbnail` field. */
|
|
308
314
|
useRawThumbnail?: boolean;
|
|
315
|
+
/** Reads only listed `imageResources` fields, other image resources are skipped without decoding them
|
|
316
|
+
* (e.g. `['resolutionInfo', 'gridAndGuidesInformation']`). Use empty array to skip all image resources.
|
|
317
|
+
* Resources needed to read layers and composite image (`alphaChannelNames`, `transparencyIndex`, layer link groups)
|
|
318
|
+
* are always read. */
|
|
319
|
+
imageResourcesWhitelist?: (keyof ImageResources)[];
|
|
309
320
|
/** Total memory limit to use when decoding bitmaps (default: 2GB). */
|
|
310
321
|
totalMemoryLimit?: number;
|
|
311
322
|
/** Usend only for development */
|
package/README_PSD.md
CHANGED
|
@@ -553,7 +553,7 @@ Example layer structure:
|
|
|
553
553
|
|
|
554
554
|
- `comps` per-layer settings for layer comps (see `layerComps` in [Image Resources](#image-resources)).
|
|
555
555
|
|
|
556
|
-
- `filterMask`, `userMask` and `filterEffectsMasks` additional mask information, `userMask.opacity` and `filterMask.opacity` values range from 0 to 1.
|
|
556
|
+
- `filterMask`, `userMask` and `filterEffectsMasks` additional mask information, `userMask.opacity` and `filterMask.opacity` values range from 0 to 1. Image data of `filterEffectsMasks` items is stored undecoded, it can be decoded using `getFilterEffectsMaskImageData` / `getFilterEffectsMaskCanvas` (color and transparency channels) and `getFilterEffectsMaskExtraImageData` / `getFilterEffectsMaskExtraCanvas` (`extra` mask) functions (see [main README document](/README.md#functions)). `colorMode` of `filterEffectsMasks` items is set to color mode of the document when reading (it's not written to the file), it's used for decoding the color channels.
|
|
557
557
|
|
|
558
558
|
- `pixelSource` video layer source information.
|
|
559
559
|
|
package/TODO.md
CHANGED
|
@@ -2,22 +2,8 @@
|
|
|
2
2
|
- Composite transparency is lost in a few files (for example 4x4_8bit_rgba, adobehq_layers: 4 channels come back as 3). I haven't investigated why.
|
|
3
3
|
- Extra layer channel IDs beyond -1/-2/-3 are dropped.
|
|
4
4
|
- Per-layer XMP (shmd → cust → layerXMP) isn't kept; only layerTime is.
|
|
5
|
-
|
|
6
|
-
|
|
7
5
|
- Lab, Multichannel and Duotone can't be read (19 corpus files) or written. Duotone could be read as grayscale while keeping its color mode data.
|
|
8
6
|
- 32-bit CMYK and 16-bit Indexed throw on read, and 32-bit CMYK can't be written.
|
|
9
7
|
- Patterns are only written as 8-bit RGB (psdWriter.ts:1175); the source mode and depth are lost.
|
|
10
8
|
- CMYK conversion ignores the embedded ICC profile and always uses the SWOP approximation.
|
|
11
|
-
|
|
12
9
|
- Not parsed: Filter Gallery (GEfc), Lens Correction (LnCr), and adjustments used as smart filters: Hue/Saturation (HStr), Exposure, Vibrance, Color Balance, Black & White, Photo Filter, Gradient Map, Selective Color, Threshold, Channel Mixer, Color Lookup, Posterize, Shadows/Highlights.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Fuzzer
|
|
16
|
-
|
|
17
|
-
- can we remove sectionDivider property ?
|
|
18
|
-
- can we remove nameSource property ?
|
|
19
|
-
|
|
20
|
-
- improve vector fill / stroke help sections
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- decompress image data in FEid section
|
package/dist/additionalInfo.js
CHANGED
|
@@ -255,6 +255,8 @@ function readVectorMask(reader, vectorMask, width, height, size) {
|
|
|
255
255
|
case 2: // Closed subpath Bezier knot, unlinked
|
|
256
256
|
case 4: // Open subpath Bezier knot, linked
|
|
257
257
|
case 5: // Open subpath Bezier knot, unlinked
|
|
258
|
+
if (!path)
|
|
259
|
+
throw new Error('Bezier knot record without subpath length record');
|
|
258
260
|
path.knots.push({ linked: (selector === 1 || selector === 4), points: readBezierKnot(reader, width, height) });
|
|
259
261
|
break;
|
|
260
262
|
case 6: // Path fill rule record
|
|
@@ -2756,7 +2758,12 @@ function createLnkHandler(tag) {
|
|
|
2756
2758
|
const seconds = (0, psdReader_1.readFloat64)(reader);
|
|
2757
2759
|
const wholeSeconds = Math.floor(seconds);
|
|
2758
2760
|
const ms = (seconds - wholeSeconds) * 1000;
|
|
2759
|
-
|
|
2761
|
+
try {
|
|
2762
|
+
file.time = (new Date(Date.UTC(year, month, day, hour, minute, wholeSeconds, ms))).toISOString();
|
|
2763
|
+
}
|
|
2764
|
+
catch (_a) {
|
|
2765
|
+
file.time = (new Date(0)).toISOString(); // invalid date
|
|
2766
|
+
}
|
|
2760
2767
|
}
|
|
2761
2768
|
const fileSize = type === 'liFE' ? readLength64(reader) : 0;
|
|
2762
2769
|
if (type === 'liFA')
|
|
@@ -2883,6 +2890,10 @@ addHandlerAlias('lnk3', 'lnk2');
|
|
|
2883
2890
|
// unicode names of saved paths (path data is stored in image resources 2000-2998)
|
|
2884
2891
|
addHandler('pths', target => { var _a; return ((_a = target.imageResources) === null || _a === void 0 ? void 0 : _a.savedPaths) !== undefined; }, (reader, _target, left, psd) => {
|
|
2885
2892
|
var _a, _b;
|
|
2893
|
+
if (reader.imageResourcesWhitelist && !reader.imageResourcesWhitelist.includes('savedPaths')) {
|
|
2894
|
+
(0, psdReader_1.skipBytes)(reader, left());
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2886
2897
|
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader, true);
|
|
2887
2898
|
const imageResources = (_a = psd.imageResources) !== null && _a !== void 0 ? _a : (psd.imageResources = {});
|
|
2888
2899
|
const savedPaths = (_b = imageResources.savedPaths) !== null && _b !== void 0 ? _b : (imageResources.savedPaths = []);
|
|
@@ -3700,7 +3711,7 @@ addHandler('Txt2', hasKey('engineData'), (reader, target, left, psd) => {
|
|
|
3700
3711
|
const buffer = (0, base64_js_1.toByteArray)(target.engineData);
|
|
3701
3712
|
(0, psdWriter_1.writeBytes)(writer, buffer);
|
|
3702
3713
|
});
|
|
3703
|
-
addHandler('FEid', hasKey('filterEffectsMasks'), (reader, target, leftBytes) => {
|
|
3714
|
+
addHandler('FEid', hasKey('filterEffectsMasks'), (reader, target, leftBytes, psd) => {
|
|
3704
3715
|
const version = (0, psdReader_1.readInt32)(reader);
|
|
3705
3716
|
if (version < 1 || version > 3)
|
|
3706
3717
|
throw new Error(`Invalid filterEffects version ${version}`);
|
|
@@ -3742,7 +3753,7 @@ addHandler('FEid', hasKey('filterEffectsMasks'), (reader, target, leftBytes) =>
|
|
|
3742
3753
|
channels.push(undefined);
|
|
3743
3754
|
}
|
|
3744
3755
|
}
|
|
3745
|
-
target.filterEffectsMasks.push({ id, top, left, bottom, right, depth, channels });
|
|
3756
|
+
target.filterEffectsMasks.push({ id, top, left, bottom, right, depth, colorMode: psd.colorMode, channels });
|
|
3746
3757
|
if (reader.offset < end && (0, psdReader_1.readUint8)(reader)) {
|
|
3747
3758
|
const top = (0, psdReader_1.readInt32)(reader);
|
|
3748
3759
|
const left = (0, psdReader_1.readInt32)(reader);
|