ag-psd 28.1.0 → 28.1.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/README.md CHANGED
@@ -164,18 +164,13 @@ Browser has to support `OffscreenCanvas` and `bitmaprenderer` context.
164
164
  importScripts('bundle.js');
165
165
 
166
166
  const createCanvas = (width, height) => {
167
- const canvas = new OffscreenCanvas(width, height);
168
- canvas.width = width;
169
- canvas.height = height;
170
- return canvas;
167
+ return new OffscreenCanvas(width, height);
171
168
  };
172
169
 
173
170
  const createCanvasFromData = (data) => {
174
171
  const image = new Image();
175
172
  image.src = 'data:image/jpeg;base64,' + agPsd.byteArrayToBase64(data);
176
173
  const canvas = new OffscreenCanvas(image.width, image.height);
177
- canvas.width = image.width;
178
- canvas.height = image.height;
179
174
  canvas.getContext('2d').drawImage(image, 0, 0);
180
175
  return canvas;
181
176
  };
@@ -227,18 +222,13 @@ xhr.send();
227
222
  importScripts('bundle.js');
228
223
 
229
224
  const createCanvas = (width, height) => {
230
- const canvas = new OffscreenCanvas(width, height);
231
- canvas.width = width;
232
- canvas.height = height;
233
- return canvas;
225
+ return OffscreenCanvas(width, height);
234
226
  };
235
227
 
236
228
  const createCanvasFromData = (data) => {
237
229
  const image = new Image();
238
230
  image.src = 'data:image/jpeg;base64,' + agPsd.byteArrayToBase64(data);
239
231
  const canvas = new OffscreenCanvas(image.width, image.height);
240
- canvas.width = image.width;
241
- canvas.height = image.height;
242
232
  canvas.getContext('2d').drawImage(image, 0, 0);
243
233
  return canvas;
244
234
  };
@@ -2883,7 +2883,8 @@ addHandler('thrs', adjustmentType('threshold'), function (reader, target, left)
2883
2883
  });
2884
2884
  var grdmColorModels = ['', '', '', 'rgb', 'hsb', '', 'lab'];
2885
2885
  addHandler('grdm', adjustmentType('gradient map'), function (reader, target, left) {
2886
- if ((0, psdReader_1.readUint16)(reader) !== 1)
2886
+ var version = (0, psdReader_1.readUint16)(reader);
2887
+ if (version !== 1 && version !== 3)
2887
2888
  throw new Error('Invalid grdm version');
2888
2889
  var info = {
2889
2890
  type: 'gradient map',
@@ -2891,6 +2892,12 @@ addHandler('grdm', adjustmentType('gradient map'), function (reader, target, lef
2891
2892
  };
2892
2893
  info.reverse = !!(0, psdReader_1.readUint8)(reader);
2893
2894
  info.dither = !!(0, psdReader_1.readUint8)(reader);
2895
+ var hasMethod = !!(0, psdReader_1.readUint8)(reader);
2896
+ reader.offset--;
2897
+ if (hasMethod) {
2898
+ var method = (0, psdReader_1.readSignature)(reader);
2899
+ info.method = descriptor_1.gradientInterpolationMethodType.decode(method);
2900
+ }
2894
2901
  info.name = (0, psdReader_1.readUnicodeString)(reader);
2895
2902
  info.colorStops = [];
2896
2903
  info.opacityStops = [];
@@ -2950,9 +2957,12 @@ addHandler('grdm', adjustmentType('gradient map'), function (reader, target, lef
2950
2957
  }, function (writer, target) {
2951
2958
  var _a, _b, _c;
2952
2959
  var info = target.adjustment;
2953
- (0, psdWriter_1.writeUint16)(writer, 1); // version
2960
+ (0, psdWriter_1.writeUint16)(writer, info.method !== undefined ? 3 : 1); // version
2954
2961
  (0, psdWriter_1.writeUint8)(writer, info.reverse ? 1 : 0);
2955
2962
  (0, psdWriter_1.writeUint8)(writer, info.dither ? 1 : 0);
2963
+ if (info.method !== undefined) {
2964
+ (0, psdWriter_1.writeSignature)(writer, descriptor_1.gradientInterpolationMethodType.encode(info.method));
2965
+ }
2956
2966
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, info.name || '');
2957
2967
  (0, psdWriter_1.writeUint16)(writer, info.colorStops && info.colorStops.length || 0);
2958
2968
  var interpolation = Math.round(((_a = info.smoothness) !== null && _a !== void 0 ? _a : 1) * 4096);