imagescript 3.14.0 → 3.16.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/README.md +14 -0
- package/dist/animation-encoder.d.ts +1 -1
- package/dist/animation-encoder.js +1 -1
- package/dist/animation.d.ts +1 -1
- package/dist/animation.js +1 -1
- package/dist/codecs/avif-enc.js +48 -19
- package/dist/codecs/avif.js +33 -4
- package/dist/codecs/gainmap.js +446 -0
- package/dist/codecs/jpeg.js +78 -16
- package/dist/codecs/jxl.js +57 -15
- package/dist/codecs/vp8l.js +65 -27
- package/dist/codecs/webp.js +7 -7
- package/dist/frame.js +4 -0
- package/dist/gainmap.d.ts +82 -0
- package/dist/gainmap.js +195 -0
- package/dist/image.d.ts +46 -4
- package/dist/image.js +278 -31
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/util/gain.js +209 -0
- package/dist/util/resample.js +203 -61
- package/dist/version.js +1 -1
- package/package.json +4 -1
package/dist/image.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ToneMapping } from './codecs/hdr.js';
|
|
|
2
2
|
import { BinaryData } from './util/mem.js';
|
|
3
3
|
import { TextLayout } from './text-layout.js';
|
|
4
4
|
import { Metadata } from './metadata.js';
|
|
5
|
+
import { GainMap } from './gainmap.js';
|
|
5
6
|
/** A color as a 32-bit RGBA integer (`0xRRGGBBAA`) */
|
|
6
7
|
export type Color = number;
|
|
7
8
|
/** Called with a pixel's (0-based) coordinates, returns its color */
|
|
@@ -65,6 +66,15 @@ export interface JPEGEncodeOptions {
|
|
|
65
66
|
quality?: number;
|
|
66
67
|
/** Metadata to include, see {@link Metadata} */
|
|
67
68
|
metadata?: Metadata;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to write the image's {@link Image.gainMap} (an Ultra HDR JPEG, brighter on HDR displays), or how:
|
|
71
|
+
* `quality` the map's JPEG quality (default: `90`), `scale` its size as a factor of the image's (0-1, default: the
|
|
72
|
+
* map's size). Default: `true` (written if there is one)
|
|
73
|
+
*/
|
|
74
|
+
gainMap?: boolean | {
|
|
75
|
+
quality?: number;
|
|
76
|
+
scale?: number;
|
|
77
|
+
};
|
|
68
78
|
}
|
|
69
79
|
/** Options of {@link Image.encodeWebP} */
|
|
70
80
|
export interface WebPEncodeOptions {
|
|
@@ -74,9 +84,12 @@ export interface WebPEncodeOptions {
|
|
|
74
84
|
*/
|
|
75
85
|
quality?: number;
|
|
76
86
|
/**
|
|
77
|
-
* How much effort
|
|
87
|
+
* How much effort compression takes (0-6): higher is smaller but slower. Lossy (libwebp's method): 0-2 pick the
|
|
78
88
|
* predictions by how close they are, 3 and up also by how many bits they take, 5 and 6 also optimize the
|
|
79
|
-
* quantized values
|
|
89
|
+
* quantized values; the default `2` takes about a quarter of the time of 4 (cwebp's default) for files about 5%
|
|
90
|
+
* larger. Lossless: 0 is a fast mode (photos in about a fifth of the time, graphics in about a third, files about
|
|
91
|
+
* 6-8% larger), 1 takes about two thirds of the time for files up to 2% larger, 2 and up compress the most.
|
|
92
|
+
* Default: `2`
|
|
80
93
|
*/
|
|
81
94
|
effort?: number;
|
|
82
95
|
/**
|
|
@@ -168,6 +181,11 @@ export interface DecodeOptions {
|
|
|
168
181
|
* brighter than white. Default: `'reinhard'`
|
|
169
182
|
*/
|
|
170
183
|
toneMapping?: ToneMapping;
|
|
184
|
+
/**
|
|
185
|
+
* Whether to read the gain maps of JPEGs (Ultra HDR, JPEG-R, ISO 21496-1, Apple's), AVIFs (tone mapped items) and
|
|
186
|
+
* JPEG XLs (jhgm boxes) into {@link Image.gainMap}. Default: `true`
|
|
187
|
+
*/
|
|
188
|
+
gainMap?: boolean;
|
|
171
189
|
/**
|
|
172
190
|
* At most this many worker threads decode in parallel (lossy JPEG XLs from 4 megapixels on, one per 2 megapixels
|
|
173
191
|
* at most, lossless ones from 1.5 megapixels and 512 KiB on; AVIFs from 4 megapixels on: the conversion to RGB,
|
|
@@ -202,6 +220,15 @@ export interface JXLEncodeOptions {
|
|
|
202
220
|
threads?: number;
|
|
203
221
|
/** Metadata to include, see {@link Metadata} */
|
|
204
222
|
metadata?: Metadata;
|
|
223
|
+
/**
|
|
224
|
+
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a jhgm box, like libjxl's), or how:
|
|
225
|
+
* `quality` (1-100 like `quality`, 100 lossless; default `90`) and `scale` (its size relative to the image, default
|
|
226
|
+
* its own). Default: `true`
|
|
227
|
+
*/
|
|
228
|
+
gainMap?: boolean | {
|
|
229
|
+
quality?: number;
|
|
230
|
+
scale?: number;
|
|
231
|
+
};
|
|
205
232
|
}
|
|
206
233
|
/** Options of {@link Image.encodeAVIF} */
|
|
207
234
|
export interface AVIFEncodeOptions {
|
|
@@ -222,6 +249,15 @@ export interface AVIFEncodeOptions {
|
|
|
222
249
|
threads?: number;
|
|
223
250
|
/** Metadata to include, see {@link Metadata} */
|
|
224
251
|
metadata?: Metadata;
|
|
252
|
+
/**
|
|
253
|
+
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a tone mapped item, like libavif
|
|
254
|
+
* writes), or how: `quality` (1-100, default `90`) and `scale` (its size relative to the image, default its own).
|
|
255
|
+
* Default: `true`
|
|
256
|
+
*/
|
|
257
|
+
gainMap?: boolean | {
|
|
258
|
+
quality?: number;
|
|
259
|
+
scale?: number;
|
|
260
|
+
};
|
|
225
261
|
}
|
|
226
262
|
/** Text style options of {@link Image.renderText} */
|
|
227
263
|
export interface TextStyle {
|
|
@@ -310,6 +346,12 @@ export declare class Image {
|
|
|
310
346
|
* @param height
|
|
311
347
|
*/
|
|
312
348
|
constructor(width: number, height: number);
|
|
349
|
+
/**
|
|
350
|
+
* The image's gain map, if it has one (JPEGs from phones, Ultra HDR): how much brighter each part gets on HDR
|
|
351
|
+
* displays. {@link Image.encodeJPEG} writes it. `null` removes it
|
|
352
|
+
*/
|
|
353
|
+
get gainMap(): GainMap | null;
|
|
354
|
+
set gainMap(gainMap: GainMap | null);
|
|
313
355
|
/**
|
|
314
356
|
* The image's RGBA pixel data. It can be replaced by any 8-bit array with width * height * 4 bytes
|
|
315
357
|
* (it is used as is, without copying)
|
|
@@ -874,7 +916,7 @@ export declare class Image {
|
|
|
874
916
|
* Encodes the image as AVIF (AV1, with an alpha image if the image has transparency)
|
|
875
917
|
* @param options See {@link AVIFEncodeOptions}
|
|
876
918
|
*/
|
|
877
|
-
encodeAVIF({ quality, alphaQuality, subsampling, effort, threads, metadata }?: AVIFEncodeOptions): Promise<Uint8Array>;
|
|
919
|
+
encodeAVIF({ quality, alphaQuality, subsampling, effort, threads, metadata, gainMap }?: AVIFEncodeOptions): Promise<Uint8Array>;
|
|
878
920
|
/**
|
|
879
921
|
* Encodes the image as JPEG XL: losslessly (the default) like libjxl's `cjxl -e 3` (a palette of up to 1024 colors,
|
|
880
922
|
* else palettes of channels using few of their values; YCoCg; the weighted predictor in contexts of its error;
|
|
@@ -885,7 +927,7 @@ export declare class Image {
|
|
|
885
927
|
* container, with the metadata as Exif
|
|
886
928
|
* @param options See {@link JXLEncodeOptions}
|
|
887
929
|
*/
|
|
888
|
-
encodeJXL({ quality, effort, threads, metadata }?: JXLEncodeOptions): Promise<Uint8Array>;
|
|
930
|
+
encodeJXL({ quality, effort, threads, metadata, gainMap }?: JXLEncodeOptions): Promise<Uint8Array>;
|
|
889
931
|
/**
|
|
890
932
|
* Encodes the image as the smallest fitting Netpbm format: PBM for black and white images, PGM for greyscale ones,
|
|
891
933
|
* PPM for others, PAM if the image has transparency
|