imagescript 1.3.0 → 3.0.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 +64 -26
- package/THIRD_PARTY_NOTICES.md +74 -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 +44 -0
- package/dist/codecs/png.js +442 -0
- package/dist/codecs/quantize.d.ts +25 -0
- package/dist/codecs/quantize.js +302 -0
- package/dist/codecs/tiff.d.ts +6 -0
- package/dist/codecs/tiff.js +546 -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 +44 -0
- package/dist/gif.js +93 -0
- package/dist/image-type.d.ts +20 -0
- package/dist/image-type.js +49 -0
- package/dist/image.d.ts +521 -0
- package/dist/image.js +1118 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +13 -0
- package/dist/package.json +1 -0
- package/dist/render/font.d.ts +63 -0
- package/dist/render/font.js +857 -0
- package/dist/render/svg.d.ts +11 -0
- package/dist/render/svg.js +1717 -0
- package/dist/render/text.d.ts +61 -0
- package/dist/render/text.js +317 -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/README.ijg +260 -0
- package/package.json +31 -7
- package/ImageScript.d.ts +0 -235
- 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/tests/gif.js +0 -0
- package/codecs/tests/jpeg.js +0 -0
- package/codecs/tests/png.js +0 -0
- package/codecs/tests/results/gif/1024.nis.gif +0 -0
- package/codecs/tests/results/gif/1024.skyra.gif +0 -0
- package/codecs/tests/results/gif/256.nis.gif +0 -0
- package/codecs/tests/results/gif/256.skyra.gif +0 -0
- package/codecs/tests/results/jpeg/256.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/256.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/256.sharp.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.sharp.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.sharp.jpeg +0 -0
- package/codecs/tests/results/png/256.jis.png +0 -0
- package/codecs/tests/results/png/256.nis.png +0 -0
- package/codecs/tests/results/png/256.sharp.png +0 -0
- package/codecs/tests/results/png/256.upng.png +0 -0
- package/codecs/tests/results/png/512.jis.png +0 -0
- package/codecs/tests/results/png/512.nis.png +0 -0
- package/codecs/tests/results/png/512.sharp.png +0 -0
- package/codecs/tests/results/png/512.upng.png +0 -0
- package/codecs/tests/results/png/64.jis.png +0 -0
- package/codecs/tests/results/png/64.nis.png +0 -0
- package/codecs/tests/results/png/64.sharp.png +0 -0
- package/codecs/tests/results/png/64.upng.png +0 -0
- package/codecs/tests/webp.js +0 -0
- 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,19 @@
|
|
|
1
|
+
import { BinaryData } from './util/mem.js';
|
|
2
|
+
import { Image } from './image.js';
|
|
3
|
+
import { GIF } from './gif.js';
|
|
4
|
+
export { Image } from './image.js';
|
|
5
|
+
export type { Color, ColorFunction, ResizeMode, SVGScaleMode, PNGMetadata, TextStyle, DecodeOptions, CompositeOptions, BlendMode, CropCircleOptions, DominantColorOptions, RotateOptions } from './image.js';
|
|
6
|
+
export { Frame } from './frame.js';
|
|
7
|
+
export type { FrameDisposalModeName, FrameDisposalModeId } from './frame.js';
|
|
8
|
+
export { GIF } from './gif.js';
|
|
9
|
+
export { TextLayout } from './text-layout.js';
|
|
10
|
+
export type { TextLayoutOptions, WrapStyle, HorizontalAlign, VerticalAlign } from './text-layout.js';
|
|
11
|
+
export { ImageType } from './image-type.js';
|
|
12
|
+
export type { ImageTypeName } from './image-type.js';
|
|
13
|
+
export type { BinaryData } from './util/mem.js';
|
|
14
|
+
/**
|
|
15
|
+
* Decodes any supported image, GIFs are returned as {@link GIF}
|
|
16
|
+
* @param data The image data
|
|
17
|
+
* @param onlyExtractFirstFrame Whether to end GIF decoding after the first frame
|
|
18
|
+
*/
|
|
19
|
+
export declare function decode(data: BinaryData, onlyExtractFirstFrame?: boolean): Promise<GIF | Image>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Image } from "./image.js";
|
|
2
|
+
import { GIF } from "./gif.js";
|
|
3
|
+
import { ImageType } from "./image-type.js";
|
|
4
|
+
export { Image } from "./image.js";
|
|
5
|
+
export { Frame } from "./frame.js";
|
|
6
|
+
export { GIF } from "./gif.js";
|
|
7
|
+
export { TextLayout } from "./text-layout.js";
|
|
8
|
+
export { ImageType } from "./image-type.js";
|
|
9
|
+
export function decode(data, onlyExtractFirstFrame = false) {
|
|
10
|
+
if (ImageType.getType(data) === 'gif')
|
|
11
|
+
return GIF.decode(data, onlyExtractFirstFrame);
|
|
12
|
+
return Image.decode(data);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
interface CFF {
|
|
7
|
+
charStrings: Uint8Array[];
|
|
8
|
+
globalSubrs: Uint8Array[];
|
|
9
|
+
privateFor: (glyph: number) => {
|
|
10
|
+
subrs: Uint8Array[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parses TrueType (glyf) and OpenType (CFF) fonts, including the first font of a collection
|
|
15
|
+
*/
|
|
16
|
+
export declare class Font {
|
|
17
|
+
data: Uint8Array;
|
|
18
|
+
view: DataView;
|
|
19
|
+
tables: Record<string, {
|
|
20
|
+
offset: number;
|
|
21
|
+
length: number;
|
|
22
|
+
}>;
|
|
23
|
+
unitsPerEm: number;
|
|
24
|
+
indexToLocFormat: number;
|
|
25
|
+
ascender: number;
|
|
26
|
+
descender: number;
|
|
27
|
+
lineGap: number;
|
|
28
|
+
numberOfHMetrics: number;
|
|
29
|
+
numGlyphs: number;
|
|
30
|
+
outlines: 'glyf' | 'cff';
|
|
31
|
+
cff: CFF | null;
|
|
32
|
+
cmap: (codepoint: number) => number;
|
|
33
|
+
outlineCache: Map<number, PathCommand[]>;
|
|
34
|
+
/** kerning between two glyphs in font units, null if the font has none */
|
|
35
|
+
kerning: ((left: number, right: number) => number) | null;
|
|
36
|
+
constructor(data: Uint8Array);
|
|
37
|
+
u8(o: number): number;
|
|
38
|
+
i8(o: number): number;
|
|
39
|
+
u16(o: number): number;
|
|
40
|
+
i16(o: number): number;
|
|
41
|
+
u32(o: number): number;
|
|
42
|
+
i32(o: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* @param {number} codepoint
|
|
45
|
+
* @return {number} glyph index, 0 (.notdef) if the font has no glyph for it
|
|
46
|
+
*/
|
|
47
|
+
glyphIndex(codepoint: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* @param {number} glyph
|
|
50
|
+
* @return {number} advance width in font units
|
|
51
|
+
*/
|
|
52
|
+
advance(glyph: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* @param {number} glyph
|
|
55
|
+
* @return {Array} path commands in font units
|
|
56
|
+
*/
|
|
57
|
+
outline(glyph: number): PathCommand[];
|
|
58
|
+
glyfOutline(glyph: number, depth: number): PathCommand[];
|
|
59
|
+
simpleGlyph(offset: number, contourCount: number): PathCommand[];
|
|
60
|
+
compositeGlyph(offset: number, depth: number): PathCommand[];
|
|
61
|
+
cffOutline(glyph: number): PathCommand[];
|
|
62
|
+
}
|
|
63
|
+
export {};
|