imagescript 1.3.1 → 3.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/LICENSE +4 -1
- package/README.md +76 -26
- package/THIRD_PARTY_NOTICES.md +156 -0
- package/dist/animation.d.ts +55 -0
- package/dist/animation.js +167 -0
- package/dist/codecs/crc.d.ts +9 -0
- package/dist/codecs/crc.js +29 -0
- package/dist/codecs/exif.d.ts +11 -0
- package/dist/codecs/exif.js +27 -0
- package/dist/codecs/gif.d.ts +44 -0
- package/dist/codecs/gif.js +401 -0
- package/dist/codecs/jpeg.d.ts +35 -0
- package/dist/codecs/jpeg.js +980 -0
- package/dist/codecs/png.d.ts +97 -0
- package/dist/codecs/png.js +664 -0
- package/dist/codecs/quantize.d.ts +25 -0
- package/dist/codecs/quantize.js +302 -0
- package/dist/codecs/tga.d.ts +16 -0
- package/dist/codecs/tga.js +203 -0
- package/dist/codecs/tiff.d.ts +6 -0
- package/dist/codecs/tiff.js +546 -0
- package/dist/codecs/vp8-tables.d.ts +10 -0
- package/dist/codecs/vp8-tables.js +17 -0
- package/dist/codecs/vp8.d.ts +8 -0
- package/dist/codecs/vp8.js +711 -0
- package/dist/codecs/vp8l.d.ts +62 -0
- package/dist/codecs/vp8l.js +909 -0
- package/dist/codecs/webp.d.ts +67 -0
- package/dist/codecs/webp.js +280 -0
- package/dist/codecs/zlib.d.ts +22 -0
- package/dist/codecs/zlib.js +607 -0
- package/dist/frame.d.ts +57 -0
- package/dist/frame.js +65 -0
- package/dist/gif.d.ts +31 -0
- package/dist/gif.js +20 -0
- package/dist/image-type.d.ts +24 -0
- package/dist/image-type.js +64 -0
- package/dist/image.d.ts +553 -0
- package/dist/image.js +1156 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +20 -0
- package/dist/package.json +1 -0
- package/dist/render/font.d.ts +92 -0
- package/dist/render/font.js +954 -0
- package/dist/render/hinting.d.ts +110 -0
- package/dist/render/hinting.js +1236 -0
- package/dist/render/svg.d.ts +11 -0
- package/dist/render/svg.js +1717 -0
- package/dist/render/text.d.ts +63 -0
- package/dist/render/text.js +342 -0
- package/dist/text-layout.d.ts +46 -0
- package/dist/text-layout.js +35 -0
- package/dist/util/blur.d.ts +13 -0
- package/dist/util/blur.js +146 -0
- package/dist/util/mem.d.ts +10 -0
- package/dist/util/mem.js +23 -0
- package/dist/util/resample.d.ts +12 -0
- package/dist/util/resample.js +99 -0
- package/dist/util/utf8.d.ts +5 -0
- package/dist/util/utf8.js +55 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/licenses/Apache-2.0.txt +202 -0
- package/licenses/FTL.txt +169 -0
- package/licenses/README.ijg +260 -0
- package/package.json +31 -7
- package/ImageScript.d.ts +0 -954
- package/ImageScript.js +0 -1669
- package/bench/_.mjs +0 -166
- package/bench/all.mjs +0 -4
- package/bench/blur.mjs +0 -59
- package/bench/flip.mjs +0 -63
- package/bench/overlay.mjs +0 -35
- package/bench/package.json +0 -7
- package/bench/readme.md +0 -64
- package/bench/resize.mjs +0 -52
- package/codecs/LICENSE +0 -21
- package/codecs/lib.d.ts +0 -50
- package/codecs/lib.js +0 -6
- package/codecs/lib.mjs +0 -1
- package/codecs/node/bin/arm64-darwin.node +0 -0
- package/codecs/node/bin/arm64-linux.node +0 -0
- package/codecs/node/bin/x64-darwin.node +0 -0
- package/codecs/node/bin/x64-linux.node +0 -0
- package/codecs/node/bin/x64-win32.node +0 -0
- package/codecs/node/index.js +0 -3
- package/codecs/node/index.mjs +0 -6
- package/codecs/package.json +0 -14
- package/codecs/readme.md +0 -38
- package/codecs/wasm/bin/codecs.wasm +0 -0
- package/codecs/wasm/bin/simd.wasm +0 -0
- package/codecs/wasm/bundle/browser.js +0 -1
- package/codecs/wasm/index.js +0 -1
- package/codecs/wasm/index.mjs +0 -1
- package/png/README.md +0 -1
- package/png/node.js +0 -1137
- package/png/src/crc.mjs +0 -49
- package/png/src/mem.mjs +0 -24
- package/png/src/png.mjs +0 -254
- package/png/src/zlib.mjs +0 -618
- package/tsconfig.json +0 -21
- package/utils/mem.js +0 -26
- package/v2/codecs/magic.js +0 -25
- package/v2/framebuffer.d.ts +0 -67
- package/v2/framebuffer.js +0 -2352
- package/v2/framebuffer.mjs +0 -126
- package/v2/framebuffer.rs +0 -1264
- package/v2/index.d.ts +0 -84
- package/v2/index.js +0 -261
- package/v2/ops/blur.mjs +0 -303
- package/v2/ops/color.mjs +0 -277
- package/v2/ops/crop.mjs +0 -64
- package/v2/ops/fill.mjs +0 -33
- package/v2/ops/flip.mjs +0 -33
- package/v2/ops/index.mjs +0 -9
- package/v2/ops/iterator.mjs +0 -34
- package/v2/ops/overlay.mjs +0 -63
- package/v2/ops/resize.mjs +0 -166
- package/v2/ops/rotate.mjs +0 -117
- package/v2/util/mem.mjs +0 -24
- package/wasm/any/font.wasm +0 -0
- package/wasm/any/gif.wasm +0 -0
- package/wasm/any/jpeg.wasm +0 -0
- package/wasm/any/png.wasm +0 -0
- package/wasm/any/svg.wasm +0 -0
- package/wasm/any/tiff.wasm +0 -0
- package/wasm/node/font.js +0 -142
- package/wasm/node/gif.js +0 -76
- package/wasm/node/jpeg.js +0 -92
- package/wasm/node/png.js +0 -49
- package/wasm/node/svg.js +0 -56
- package/wasm/node/tiff.js +0 -47
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BinaryData } from './util/mem.js';
|
|
2
|
+
import { Image } from './image.js';
|
|
3
|
+
import { GIF } from './gif.js';
|
|
4
|
+
import { Animation } from './animation.js';
|
|
5
|
+
export { Image } from './image.js';
|
|
6
|
+
export type { Color, ColorFunction, ResizeMode, SVGScaleMode, PNGMetadata, TextStyle, DecodeOptions, CompositeOptions, BlendMode, CropCircleOptions, DominantColorOptions, RotateOptions, ColorToAlphaOptions } from './image.js';
|
|
7
|
+
export { Frame } from './frame.js';
|
|
8
|
+
export type { FrameDisposalModeName, FrameDisposalModeId } from './frame.js';
|
|
9
|
+
export { GIF } from './gif.js';
|
|
10
|
+
export { Animation } from './animation.js';
|
|
11
|
+
export { TextLayout } from './text-layout.js';
|
|
12
|
+
export type { TextLayoutOptions, WrapStyle, HorizontalAlign, VerticalAlign } from './text-layout.js';
|
|
13
|
+
export { ImageType } from './image-type.js';
|
|
14
|
+
export type { ImageTypeName } from './image-type.js';
|
|
15
|
+
export type { BinaryData } from './util/mem.js';
|
|
16
|
+
/**
|
|
17
|
+
* Decodes any supported image: GIFs are returned as {@link GIF} (an {@link Animation}), animated WebPs as
|
|
18
|
+
* {@link Animation}, everything else (including APNGs, as their default image) as {@link Image}.
|
|
19
|
+
* {@link Animation.decode} decodes the frames of GIFs, APNGs and WebPs
|
|
20
|
+
* @param data The image data
|
|
21
|
+
* @param onlyExtractFirstFrame Whether to end animation decoding after the first frame
|
|
22
|
+
*/
|
|
23
|
+
export declare function decode(data: BinaryData, onlyExtractFirstFrame?: boolean): Promise<GIF | Animation | Image>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Image } from "./image.js";
|
|
2
|
+
import { GIF } from "./gif.js";
|
|
3
|
+
import { Animation } from "./animation.js";
|
|
4
|
+
import * as webp from "./codecs/webp.js";
|
|
5
|
+
import { view } from "./util/mem.js";
|
|
6
|
+
import { ImageType } from "./image-type.js";
|
|
7
|
+
export { Image } from "./image.js";
|
|
8
|
+
export { Frame } from "./frame.js";
|
|
9
|
+
export { GIF } from "./gif.js";
|
|
10
|
+
export { Animation } from "./animation.js";
|
|
11
|
+
export { TextLayout } from "./text-layout.js";
|
|
12
|
+
export { ImageType } from "./image-type.js";
|
|
13
|
+
export function decode(data, onlyExtractFirstFrame = false) {
|
|
14
|
+
const type = ImageType.getType(data);
|
|
15
|
+
if (type === 'gif')
|
|
16
|
+
return GIF.decode(data, onlyExtractFirstFrame);
|
|
17
|
+
if (type === 'webp' && webp.isAnimated(view(data)))
|
|
18
|
+
return Animation.decode(data, onlyExtractFirstFrame);
|
|
19
|
+
return Image.decode(data);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path command in font units (y up) or user units:
|
|
3
|
+
* ['M', x, y], ['L', x, y], ['Q', cx, cy, x, y], ['C', c1x, c1y, c2x, c2y, x, y], ['Z']
|
|
4
|
+
*/
|
|
5
|
+
export type PathCommand = [string, ...number[]];
|
|
6
|
+
/** a TrueType glyph's points (font units) and instructions, for hinting */
|
|
7
|
+
export interface GlyfPoints {
|
|
8
|
+
xs: number[];
|
|
9
|
+
ys: number[];
|
|
10
|
+
/** on curve flags */
|
|
11
|
+
on: boolean[];
|
|
12
|
+
/** index of the last point of every contour */
|
|
13
|
+
ends: number[];
|
|
14
|
+
instructions: Uint8Array;
|
|
15
|
+
/** glyph bounding box minimum x (the left side bearing's reference) */
|
|
16
|
+
xMin: number;
|
|
17
|
+
/** components of composite glyphs (their points are not included in xs/ys) */
|
|
18
|
+
components: Array<{
|
|
19
|
+
glyph: number;
|
|
20
|
+
dx: number;
|
|
21
|
+
dy: number;
|
|
22
|
+
matrix: [number, number, number, number];
|
|
23
|
+
round: boolean;
|
|
24
|
+
match: [number, number] | null;
|
|
25
|
+
useMetrics: boolean;
|
|
26
|
+
}> | null;
|
|
27
|
+
}
|
|
28
|
+
interface CFF {
|
|
29
|
+
charStrings: Uint8Array[];
|
|
30
|
+
globalSubrs: Uint8Array[];
|
|
31
|
+
privateFor: (glyph: number) => {
|
|
32
|
+
subrs: Uint8Array[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parses TrueType (glyf) and OpenType (CFF) fonts, including the first font of a collection
|
|
37
|
+
*/
|
|
38
|
+
export declare class Font {
|
|
39
|
+
data: Uint8Array;
|
|
40
|
+
view: DataView;
|
|
41
|
+
tables: Record<string, {
|
|
42
|
+
offset: number;
|
|
43
|
+
length: number;
|
|
44
|
+
}>;
|
|
45
|
+
unitsPerEm: number;
|
|
46
|
+
indexToLocFormat: number;
|
|
47
|
+
ascender: number;
|
|
48
|
+
descender: number;
|
|
49
|
+
lineGap: number;
|
|
50
|
+
numberOfHMetrics: number;
|
|
51
|
+
numGlyphs: number;
|
|
52
|
+
outlines: 'glyf' | 'cff';
|
|
53
|
+
cff: CFF | null;
|
|
54
|
+
cmap: (codepoint: number) => number;
|
|
55
|
+
outlineCache: Map<number, PathCommand[]>;
|
|
56
|
+
/** kerning between two glyphs in font units, null if the font has none */
|
|
57
|
+
kerning: ((left: number, right: number) => number) | null;
|
|
58
|
+
constructor(data: Uint8Array);
|
|
59
|
+
u8(o: number): number;
|
|
60
|
+
i8(o: number): number;
|
|
61
|
+
u16(o: number): number;
|
|
62
|
+
i16(o: number): number;
|
|
63
|
+
u32(o: number): number;
|
|
64
|
+
i32(o: number): number;
|
|
65
|
+
/**
|
|
66
|
+
* @param {number} codepoint
|
|
67
|
+
* @return {number} glyph index, 0 (.notdef) if the font has no glyph for it
|
|
68
|
+
*/
|
|
69
|
+
glyphIndex(codepoint: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* @param {number} glyph
|
|
72
|
+
* @return {number} advance width in font units
|
|
73
|
+
*/
|
|
74
|
+
advance(glyph: number): number;
|
|
75
|
+
/** left side bearing in font units */
|
|
76
|
+
leftSideBearing(glyph: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* A TrueType glyph's points and instructions (null for empty glyphs or CFF fonts)
|
|
79
|
+
*/
|
|
80
|
+
glyfPoints(glyph: number): GlyfPoints | null;
|
|
81
|
+
/**
|
|
82
|
+
* @param {number} glyph
|
|
83
|
+
* @return {Array} path commands in font units
|
|
84
|
+
*/
|
|
85
|
+
outline(glyph: number): PathCommand[];
|
|
86
|
+
glyfOutline(glyph: number, depth: number): PathCommand[];
|
|
87
|
+
simpleGlyph(offset: number, contourCount: number): PathCommand[];
|
|
88
|
+
compositeGlyph(offset: number, depth: number): PathCommand[];
|
|
89
|
+
cffOutline(glyph: number): PathCommand[];
|
|
90
|
+
}
|
|
91
|
+
export declare function contourToPath(path: PathCommand[], xs: ArrayLike<number>, ys: ArrayLike<number>, flags: ArrayLike<number | boolean>, first: number, last: number): void;
|
|
92
|
+
export {};
|