imagescript 3.20.3 → 4.0.0-rc.2
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/LICENSE +16 -12
- package/README.md +21 -12
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/animation-encoder.d.ts +1 -34
- package/dist/animation-encoder.js +35 -34
- package/dist/animation.d.ts +108 -122
- package/dist/animation.js +285 -121
- package/dist/codecs/av1/decode.js +1 -1
- package/dist/codecs/av1/encode.js +1 -1
- package/dist/codecs/gif.js +11 -9
- package/dist/codecs/hdr.d.ts +1 -1
- package/dist/codecs/jpeg.js +13 -13
- package/dist/codecs/jxl/headers.js +3 -3
- package/dist/codecs/jxl/patches-enc.js +1 -1
- package/dist/codecs/jxl.js +5 -5
- package/dist/codecs/netpbm.js +7 -7
- package/dist/codecs/png.js +15 -15
- package/dist/codecs/quantize.js +34 -8
- package/dist/codecs/tiff.js +1 -1
- package/dist/codecs/webp.js +3 -3
- package/dist/codecs/zlib.js +1 -1
- package/dist/colors.d.ts +8 -7
- package/dist/colors.js +23 -3
- package/dist/frame.d.ts +94 -100
- package/dist/frame.js +89 -65
- package/dist/gainmap.d.ts +88 -46
- package/dist/gainmap.js +75 -51
- package/dist/image-type.d.ts +6 -1
- package/dist/image-type.js +4 -1
- package/dist/image.d.ts +317 -738
- package/dist/image.js +308 -438
- package/dist/index.d.ts +19 -25
- package/dist/index.js +15 -14
- package/dist/metadata.d.ts +4 -3
- package/dist/metadata.js +9 -7
- package/dist/render/colr.js +1 -1
- package/dist/render/font.js +1 -1
- package/dist/render/layout.js +1 -1
- package/dist/render/segment.js +1 -1
- package/dist/render/shapers/hangul.js +1 -1
- package/dist/render/svg.js +68 -20
- package/dist/render/text.js +7 -9
- package/dist/text-layout.d.ts +5 -35
- package/dist/text-layout.js +11 -12
- package/dist/util/gain.js +12 -12
- package/dist/util/mem.d.ts +1 -1
- package/dist/util/optimize.js +3 -1
- package/dist/util/options.js +46 -7
- package/package.json +15 -10
- package/LICENSE.AGPL-3.0 +0 -619
- package/LICENSE.MIT +0 -19
- package/dist/gif.d.ts +0 -36
- package/dist/gif.js +0 -22
- package/dist/util/rotate.js +0 -43
- package/dist/version.js +0 -1
package/dist/gif.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { view } from "./util/mem.js";
|
|
2
|
-
import { ImageType } from "./image-type.js";
|
|
3
|
-
import { Animation } from "./animation.js";
|
|
4
|
-
import { isOptions } from "./util/options.js";
|
|
5
|
-
export class GIF extends Animation {
|
|
6
|
-
constructor(frames, loopCountOrOptions) {
|
|
7
|
-
super(frames, loopCountOrOptions);
|
|
8
|
-
}
|
|
9
|
-
toString() {
|
|
10
|
-
return `GIF<${this.width}x${this.height}x${this.duration}ms>`;
|
|
11
|
-
}
|
|
12
|
-
async encode(qualityOrOptions) {
|
|
13
|
-
return this.encodeGIF(qualityOrOptions);
|
|
14
|
-
}
|
|
15
|
-
static async decode(input, onlyFirstFrameOrOptions = false) {
|
|
16
|
-
const { onlyFirstFrame = false, maxPixels } = isOptions(onlyFirstFrameOrOptions) ? onlyFirstFrameOrOptions : { onlyFirstFrame: onlyFirstFrameOrOptions };
|
|
17
|
-
const data = view(input);
|
|
18
|
-
if (!ImageType.isGIF(new DataView(data.buffer, data.byteOffset, data.byteLength)))
|
|
19
|
-
throw new Error('Unsupported image type');
|
|
20
|
-
return Animation.__fromGIF__(data, onlyFirstFrame, GIF, maxPixels);
|
|
21
|
-
}
|
|
22
|
-
}
|
package/dist/util/rotate.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { littleEndian, isOpaque, premultiply8, unpremultiply8 } from "./alpha.js";
|
|
2
|
-
function span(start, step, limit, from, to) {
|
|
3
|
-
if (step === 0)
|
|
4
|
-
return start >= 0 && start < limit ? [from, to] : [from, from];
|
|
5
|
-
const a = -start / step, b = (limit - start) / step;
|
|
6
|
-
const lo = Math.floor(Math.min(a, b)) - 1, hi = Math.ceil(Math.max(a, b)) + 1;
|
|
7
|
-
return [Math.max(from, lo), Math.max(Math.max(from, lo), Math.min(to, hi))];
|
|
8
|
-
}
|
|
9
|
-
export function rotateBilinear(src, width, height, out, outWidth, outHeight, sin, cos) {
|
|
10
|
-
if (!littleEndian)
|
|
11
|
-
return false;
|
|
12
|
-
let bitmap = src;
|
|
13
|
-
if (!isOpaque(src))
|
|
14
|
-
premultiply8(src, bitmap = new Uint8ClampedArray(src.length));
|
|
15
|
-
const pixels = new Int32Array(bitmap.buffer, bitmap.byteOffset, width * height);
|
|
16
|
-
const stride = width + 2;
|
|
17
|
-
const padded = new Int32Array(stride * (height + 2));
|
|
18
|
-
for (let y = 0; y < height; y++)
|
|
19
|
-
padded.set(pixels.subarray(y * width, (y + 1) * width), (y + 1) * stride + 1);
|
|
20
|
-
const result = new Int32Array(out.buffer, out.byteOffset, outWidth * outHeight);
|
|
21
|
-
const x0 = 0.5 - outWidth / 2, cx = width / 2 + 0.5, cy = height / 2 + 0.5;
|
|
22
|
-
for (let oy = 0; oy < outHeight; oy++) {
|
|
23
|
-
const dy = oy + 0.5 - outHeight / 2;
|
|
24
|
-
const sx0 = x0 * cos - dy * sin + cx, sy0 = x0 * sin + dy * cos + cy;
|
|
25
|
-
const [xFrom, xTo] = span(sx0, cos, width + 1, 0, outWidth);
|
|
26
|
-
const [from, to] = span(sy0, sin, height + 1, xFrom, xTo);
|
|
27
|
-
let o = oy * outWidth + from, sx = sx0 + from * cos, sy = sy0 + from * sin;
|
|
28
|
-
for (let ox = from; ox < to; ox++, o++, sx += cos, sy += sin) {
|
|
29
|
-
if (!(sx >= 0 && sy >= 0 && sx < width + 1 && sy < height + 1))
|
|
30
|
-
continue;
|
|
31
|
-
const ix = sx | 0, iy = sy | 0;
|
|
32
|
-
const fx = (sx - ix) * 256 + 0.5 | 0, fy = (sy - iy) * 256 + 0.5 | 0;
|
|
33
|
-
const w11 = fx * fy + 128 >> 8, w10 = fx - w11, w01 = fy - w11, w00 = 256 - fx - fy + w11;
|
|
34
|
-
const i = iy * stride + ix;
|
|
35
|
-
const p00 = padded[i], p10 = padded[i + 1], p01 = padded[i + stride], p11 = padded[i + stride + 1];
|
|
36
|
-
const rb = Math.imul(p00 & 0xff00ff, w00) + Math.imul(p10 & 0xff00ff, w10) + Math.imul(p01 & 0xff00ff, w01) + Math.imul(p11 & 0xff00ff, w11) + 0x800080;
|
|
37
|
-
const ga = Math.imul(p00 >>> 8 & 0xff00ff, w00) + Math.imul(p10 >>> 8 & 0xff00ff, w10) + Math.imul(p01 >>> 8 & 0xff00ff, w01) + Math.imul(p11 >>> 8 & 0xff00ff, w11) + 0x800080;
|
|
38
|
-
result[o] = (rb >>> 8 & 0xff00ff) | (ga & 0xff00ff00);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
unpremultiply8(out);
|
|
42
|
-
return true;
|
|
43
|
-
}
|
package/dist/version.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const VERSION = '3.20.3';
|