imagescript 3.0.0 → 3.2.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 +29 -9
- package/THIRD_PARTY_NOTICES.md +82 -0
- package/dist/animation.d.ts +140 -0
- package/dist/animation.js +197 -0
- package/dist/codecs/exif.js +62 -0
- package/dist/codecs/gif.js +32 -19
- package/dist/codecs/jpeg.js +13 -1
- package/dist/codecs/png.js +348 -62
- package/dist/codecs/quantize.js +2 -2
- package/dist/codecs/tga.js +246 -0
- package/dist/codecs/vp8-tables.js +17 -0
- package/dist/codecs/vp8.js +711 -0
- package/dist/codecs/vp8l.js +906 -0
- package/dist/codecs/webp.js +293 -0
- package/dist/frame.d.ts +40 -12
- package/dist/frame.js +20 -9
- package/dist/gif.d.ts +16 -26
- package/dist/gif.js +10 -81
- package/dist/image-type.d.ts +6 -1
- package/dist/image-type.js +17 -1
- package/dist/image.d.ts +262 -30
- package/dist/image.js +144 -45
- package/dist/index.d.ts +20 -6
- package/dist/index.js +13 -4
- package/dist/metadata.d.ts +35 -0
- package/dist/metadata.js +43 -0
- package/dist/render/font.js +99 -2
- package/dist/render/hinting.js +1236 -0
- package/dist/render/svg.js +39 -21
- package/dist/render/text.js +32 -7
- package/dist/util/optimize.js +264 -0
- package/dist/util/options.js +3 -0
- package/dist/util/resample.js +44 -26
- package/dist/util/utf8.js +4 -51
- package/dist/version.js +1 -1
- package/licenses/FTL.txt +169 -0
- package/package.json +10 -3
- package/dist/codecs/crc.d.ts +0 -9
- package/dist/codecs/exif.d.ts +0 -11
- package/dist/codecs/gif.d.ts +0 -44
- package/dist/codecs/jpeg.d.ts +0 -35
- package/dist/codecs/png.d.ts +0 -44
- package/dist/codecs/quantize.d.ts +0 -25
- package/dist/codecs/tiff.d.ts +0 -6
- package/dist/codecs/zlib.d.ts +0 -22
- package/dist/render/font.d.ts +0 -63
- package/dist/render/svg.d.ts +0 -11
- package/dist/render/text.d.ts +0 -61
- package/dist/util/blur.d.ts +0 -13
- package/dist/util/resample.d.ts +0 -12
- package/dist/util/utf8.d.ts +0 -5
- package/dist/version.d.ts +0 -1
package/licenses/FTL.txt
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
The FreeType Project LICENSE
|
|
2
|
+
----------------------------
|
|
3
|
+
|
|
4
|
+
2006-Jan-27
|
|
5
|
+
|
|
6
|
+
Copyright 1996-2002, 2006 by
|
|
7
|
+
David Turner, Robert Wilhelm, and Werner Lemberg
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Introduction
|
|
12
|
+
============
|
|
13
|
+
|
|
14
|
+
The FreeType Project is distributed in several archive packages;
|
|
15
|
+
some of them may contain, in addition to the FreeType font engine,
|
|
16
|
+
various tools and contributions which rely on, or relate to, the
|
|
17
|
+
FreeType Project.
|
|
18
|
+
|
|
19
|
+
This license applies to all files found in such packages, and
|
|
20
|
+
which do not fall under their own explicit license. The license
|
|
21
|
+
affects thus the FreeType font engine, the test programs,
|
|
22
|
+
documentation and makefiles, at the very least.
|
|
23
|
+
|
|
24
|
+
This license was inspired by the BSD, Artistic, and IJG
|
|
25
|
+
(Independent JPEG Group) licenses, which all encourage inclusion
|
|
26
|
+
and use of free software in commercial and freeware products
|
|
27
|
+
alike. As a consequence, its main points are that:
|
|
28
|
+
|
|
29
|
+
o We don't promise that this software works. However, we will be
|
|
30
|
+
interested in any kind of bug reports. (`as is' distribution)
|
|
31
|
+
|
|
32
|
+
o You can use this software for whatever you want, in parts or
|
|
33
|
+
full form, without having to pay us. (`royalty-free' usage)
|
|
34
|
+
|
|
35
|
+
o You may not pretend that you wrote this software. If you use
|
|
36
|
+
it, or only parts of it, in a program, you must acknowledge
|
|
37
|
+
somewhere in your documentation that you have used the
|
|
38
|
+
FreeType code. (`credits')
|
|
39
|
+
|
|
40
|
+
We specifically permit and encourage the inclusion of this
|
|
41
|
+
software, with or without modifications, in commercial products.
|
|
42
|
+
We disclaim all warranties covering The FreeType Project and
|
|
43
|
+
assume no liability related to The FreeType Project.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Finally, many people asked us for a preferred form for a
|
|
47
|
+
credit/disclaimer to use in compliance with this license. We thus
|
|
48
|
+
encourage you to use the following text:
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
Portions of this software are copyright © <year> The FreeType
|
|
52
|
+
Project (https://freetype.org). All rights reserved.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
Please replace <year> with the value from the FreeType version you
|
|
56
|
+
actually use.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Legal Terms
|
|
60
|
+
===========
|
|
61
|
+
|
|
62
|
+
0. Definitions
|
|
63
|
+
--------------
|
|
64
|
+
|
|
65
|
+
Throughout this license, the terms `package', `FreeType Project',
|
|
66
|
+
and `FreeType archive' refer to the set of files originally
|
|
67
|
+
distributed by the authors (David Turner, Robert Wilhelm, and
|
|
68
|
+
Werner Lemberg) as the `FreeType Project', be they named as alpha,
|
|
69
|
+
beta or final release.
|
|
70
|
+
|
|
71
|
+
`You' refers to the licensee, or person using the project, where
|
|
72
|
+
`using' is a generic term including compiling the project's source
|
|
73
|
+
code as well as linking it to form a `program' or `executable'.
|
|
74
|
+
This program is referred to as `a program using the FreeType
|
|
75
|
+
engine'.
|
|
76
|
+
|
|
77
|
+
This license applies to all files distributed in the original
|
|
78
|
+
FreeType Project, including all source code, binaries and
|
|
79
|
+
documentation, unless otherwise stated in the file in its
|
|
80
|
+
original, unmodified form as distributed in the original archive.
|
|
81
|
+
If you are unsure whether or not a particular file is covered by
|
|
82
|
+
this license, you must contact us to verify this.
|
|
83
|
+
|
|
84
|
+
The FreeType Project is copyright (C) 1996-2000 by David Turner,
|
|
85
|
+
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
|
86
|
+
specified below.
|
|
87
|
+
|
|
88
|
+
1. No Warranty
|
|
89
|
+
--------------
|
|
90
|
+
|
|
91
|
+
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
|
92
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
93
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
94
|
+
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
|
95
|
+
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
|
96
|
+
USE, OF THE FREETYPE PROJECT.
|
|
97
|
+
|
|
98
|
+
2. Redistribution
|
|
99
|
+
-----------------
|
|
100
|
+
|
|
101
|
+
This license grants a worldwide, royalty-free, perpetual and
|
|
102
|
+
irrevocable right and license to use, execute, perform, compile,
|
|
103
|
+
display, copy, create derivative works of, distribute and
|
|
104
|
+
sublicense the FreeType Project (in both source and object code
|
|
105
|
+
forms) and derivative works thereof for any purpose; and to
|
|
106
|
+
authorize others to exercise some or all of the rights granted
|
|
107
|
+
herein, subject to the following conditions:
|
|
108
|
+
|
|
109
|
+
o Redistribution of source code must retain this license file
|
|
110
|
+
(`FTL.TXT') unaltered; any additions, deletions or changes to
|
|
111
|
+
the original files must be clearly indicated in accompanying
|
|
112
|
+
documentation. The copyright notices of the unaltered,
|
|
113
|
+
original files must be preserved in all copies of source
|
|
114
|
+
files.
|
|
115
|
+
|
|
116
|
+
o Redistribution in binary form must provide a disclaimer that
|
|
117
|
+
states that the software is based in part of the work of the
|
|
118
|
+
FreeType Team, in the distribution documentation. We also
|
|
119
|
+
encourage you to put an URL to the FreeType web page in your
|
|
120
|
+
documentation, though this isn't mandatory.
|
|
121
|
+
|
|
122
|
+
These conditions apply to any software derived from or based on
|
|
123
|
+
the FreeType Project, not just the unmodified files. If you use
|
|
124
|
+
our work, you must acknowledge us. However, no fee need be paid
|
|
125
|
+
to us.
|
|
126
|
+
|
|
127
|
+
3. Advertising
|
|
128
|
+
--------------
|
|
129
|
+
|
|
130
|
+
Neither the FreeType authors and contributors nor you shall use
|
|
131
|
+
the name of the other for commercial, advertising, or promotional
|
|
132
|
+
purposes without specific prior written permission.
|
|
133
|
+
|
|
134
|
+
We suggest, but do not require, that you use one or more of the
|
|
135
|
+
following phrases to refer to this software in your documentation
|
|
136
|
+
or advertising materials: `FreeType Project', `FreeType Engine',
|
|
137
|
+
`FreeType library', or `FreeType Distribution'.
|
|
138
|
+
|
|
139
|
+
As you have not signed this license, you are not required to
|
|
140
|
+
accept it. However, as the FreeType Project is copyrighted
|
|
141
|
+
material, only this license, or another one contracted with the
|
|
142
|
+
authors, grants you the right to use, distribute, and modify it.
|
|
143
|
+
Therefore, by using, distributing, or modifying the FreeType
|
|
144
|
+
Project, you indicate that you understand and accept all the terms
|
|
145
|
+
of this license.
|
|
146
|
+
|
|
147
|
+
4. Contacts
|
|
148
|
+
-----------
|
|
149
|
+
|
|
150
|
+
There are two mailing lists related to FreeType:
|
|
151
|
+
|
|
152
|
+
o freetype@nongnu.org
|
|
153
|
+
|
|
154
|
+
Discusses general use and applications of FreeType, as well as
|
|
155
|
+
future and wanted additions to the library and distribution.
|
|
156
|
+
If you are looking for support, start in this list if you
|
|
157
|
+
haven't found anything to help you in the documentation.
|
|
158
|
+
|
|
159
|
+
o freetype-devel@nongnu.org
|
|
160
|
+
|
|
161
|
+
Discusses bugs, as well as engine internals, design issues,
|
|
162
|
+
specific licenses, porting, etc.
|
|
163
|
+
|
|
164
|
+
Our home page can be found at
|
|
165
|
+
|
|
166
|
+
https://freetype.org
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
--- end of FTL.TXT ---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imagescript",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "zero-dependency javascript image manipulation",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"docs": "node scripts/docs.js",
|
|
28
28
|
"test": "npm run build && node ./tests/run.js",
|
|
29
29
|
"prepack": "npm run build",
|
|
30
|
-
"version": "node scripts/
|
|
30
|
+
"version": "node scripts/version.js && git add src/version.ts jsr.json"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -47,7 +47,14 @@
|
|
|
47
47
|
"bitmap",
|
|
48
48
|
"gif",
|
|
49
49
|
"picture",
|
|
50
|
-
"thumbnail"
|
|
50
|
+
"thumbnail",
|
|
51
|
+
"webp",
|
|
52
|
+
"apng",
|
|
53
|
+
"tiff",
|
|
54
|
+
"tga",
|
|
55
|
+
"animation",
|
|
56
|
+
"text rendering",
|
|
57
|
+
"font"
|
|
51
58
|
],
|
|
52
59
|
"author": "Mathis Mensing <mathis@matmen.dev>",
|
|
53
60
|
"license": "(AGPL-3.0-or-later OR MIT)",
|
package/dist/codecs/crc.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Slice-by-16 CRC-32, derived from "Fast CRC32 in JavaScript" (https://gist.github.com/101arrowz/e58695f7ccfdf74f60ba22018093edea)
|
|
3
|
-
* Copyright (c) 2021 Arjun Barrett, MIT License (see THIRD_PARTY_NOTICES.md)
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* CRC-32 (ISO 3309), as used by PNG and zlib. Processes 16 bytes per step (slice-by-16, see #12), byte by byte so
|
|
7
|
-
* it doesn't depend on alignment or endianness
|
|
8
|
-
*/
|
|
9
|
-
export declare function crc32(buffer: Uint8Array): number;
|
package/dist/codecs/exif.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads the orientation tag (0x0112) from the first IFD of Exif data
|
|
3
|
-
* @param data a TIFF header and IFDs, optionally preceded by "Exif\0\0" (as in JPEG's APP1)
|
|
4
|
-
* @return the orientation (1-8), 1 if it is missing or invalid
|
|
5
|
-
*/
|
|
6
|
-
export declare function orientation(data: Uint8Array): number;
|
|
7
|
-
/**
|
|
8
|
-
* Reads tiff:Orientation from an XMP packet, as attribute or element
|
|
9
|
-
* @return the orientation (1-8), 1 if it is missing or invalid
|
|
10
|
-
*/
|
|
11
|
-
export declare function xmpOrientation(xmp: string): number;
|
package/dist/codecs/gif.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface GIFFrame {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
/** Frame delay in centiseconds */
|
|
7
|
-
delay: number;
|
|
8
|
-
/** ImageScript disposal mode (0 any, 1 keep, 2 previous, 3 background) */
|
|
9
|
-
dispose: number;
|
|
10
|
-
/** RGBA pixel data */
|
|
11
|
-
pixels: Uint8Array;
|
|
12
|
-
}
|
|
13
|
-
export interface GIFData {
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
/** -1 loops forever, 0 plays once, n repeats n times */
|
|
17
|
-
loopCount: number;
|
|
18
|
-
frames: GIFFrame[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Encodes frames into a GIF
|
|
22
|
-
* @param {{width: number, height: number, loopCount?: number, frames: GIFFrame[]}} gif loopCount -1 loops forever, 0 plays once, n repeats n times
|
|
23
|
-
* @param {number} [quality=95] 1-100, scales the palette size (1 = 8 colors, 50 = 55, 90 and above = 256)
|
|
24
|
-
* @return {Uint8Array}
|
|
25
|
-
*/
|
|
26
|
-
export declare function encode({ width, height, loopCount, frames }: Omit<GIFData, 'loopCount'> & {
|
|
27
|
-
loopCount?: number;
|
|
28
|
-
}, quality?: number): Uint8Array;
|
|
29
|
-
/**
|
|
30
|
-
* Decodes a GIF into its individual (uncomposited) frames, zero-sized images are skipped
|
|
31
|
-
* @param {Uint8Array} data
|
|
32
|
-
* @param {boolean} [onlyFirstFrame=false]
|
|
33
|
-
* @return {{width: number, height: number, loopCount: number, frames: GIFFrame[]}}
|
|
34
|
-
*/
|
|
35
|
-
export declare function decode(data: Uint8Array, onlyFirstFrame?: boolean): GIFData;
|
|
36
|
-
/**
|
|
37
|
-
* Composites decoded frames onto the logical screen, applying their disposal modes
|
|
38
|
-
* @param {{width: number, height: number, frames: GIFFrame[]}} gif output of {@link decode}
|
|
39
|
-
* @return {Array<{pixels: Uint8Array, delay: number}>} full screen RGBA frames
|
|
40
|
-
*/
|
|
41
|
-
export declare function composite({ width, height, frames }: GIFData): Array<{
|
|
42
|
-
pixels: Uint8Array;
|
|
43
|
-
delay: number;
|
|
44
|
-
}>;
|
package/dist/codecs/jpeg.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* JPEG codec. This software is based in part on the work of the Independent JPEG Group: the IDCT, FDCT, upsampling,
|
|
3
|
-
* color conversion, progressive refinement and optimal Huffman tables are translated from libjpeg/libjpeg-turbo
|
|
4
|
-
* (IJG license, see licenses/README.ijg). The scan decoder follows the structure of pdf.js' jpg.js
|
|
5
|
-
* (Copyright 2014 Mozilla Foundation, Apache License 2.0). See THIRD_PARTY_NOTICES.md
|
|
6
|
-
*/
|
|
7
|
-
export interface DecodeOptions {
|
|
8
|
-
/** overrides the color transform detected from JFIF/Adobe markers (used by TIFF) */
|
|
9
|
-
transform?: 'ycc' | 'rgb' | 'cmyk' | null;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Decodes a JPEG into 8-bit RGBA pixel data
|
|
13
|
-
* Supports baseline, extended and progressive huffman coded JPEGs with any
|
|
14
|
-
* sampling factors, restart intervals and greyscale, YCbCr, RGB, CMYK and YCCK color
|
|
15
|
-
* The output matches libjpeg's defaults (islow IDCT, fancy upsampling)
|
|
16
|
-
* @param {Uint8Array} data
|
|
17
|
-
* @param {{transform?: 'ycc'|'rgb'|'cmyk'}} [options] overrides the color transform detected from JFIF/Adobe markers (used by TIFF)
|
|
18
|
-
* @return {{width: number, height: number, pixels: Uint8Array}}
|
|
19
|
-
*/
|
|
20
|
-
export declare function decode(data: Uint8Array, { transform }?: DecodeOptions): {
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
pixels: Uint8Array;
|
|
24
|
-
orientation: number;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Encodes RGBA pixel data into a baseline JPEG (alpha is ignored)
|
|
28
|
-
* Uses 4:2:0 chroma subsampling up to quality 90 and 4:4:4 above, with optimized huffman tables
|
|
29
|
-
* @param {Uint8Array} pixels
|
|
30
|
-
* @param {number} width
|
|
31
|
-
* @param {number} height
|
|
32
|
-
* @param {number} [quality=90] 1-100
|
|
33
|
-
* @return {Uint8Array}
|
|
34
|
-
*/
|
|
35
|
-
export declare function encode(pixels: Uint8Array, width: number, height: number, quality?: number): Uint8Array;
|
package/dist/codecs/png.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface EncodeOptions {
|
|
2
|
-
/** tEXt chunks, empty values are skipped */
|
|
3
|
-
text?: Record<string, string | undefined>;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
channels: number;
|
|
7
|
-
depth?: number;
|
|
8
|
-
level?: number;
|
|
9
|
-
/** packed RGB palette, makes the data palette indices (1 channel) */
|
|
10
|
-
palette?: Uint8Array;
|
|
11
|
-
/** alpha per palette entry */
|
|
12
|
-
transparency?: Uint8Array;
|
|
13
|
-
/** whether to paeth filter the rows (pays off for truecolor and greyscale images) */
|
|
14
|
-
filter?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface Decoded {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
/** 8-bit RGBA */
|
|
20
|
-
pixels: Uint8Array;
|
|
21
|
-
/** Exif orientation (1-8) */
|
|
22
|
-
orientation: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Encodes raw pixel data into a PNG
|
|
26
|
-
* @param data Raw pixel data, rows packed MSB first for depths below 8
|
|
27
|
-
*/
|
|
28
|
-
export declare function encode(data: Uint8Array, { text, width, height, channels, depth, level, palette, transparency, filter: filterRows }: EncodeOptions): Promise<Uint8Array>;
|
|
29
|
-
/**
|
|
30
|
-
* Encodes 8-bit RGBA pixels into a PNG with the smallest lossless color type:
|
|
31
|
-
* a palette for up to 256 colors, otherwise greyscale or RGB, with alpha only if a pixel isn't opaque.
|
|
32
|
-
* Rows of non-palette images are paeth filtered (unless the data isn't compressed), palette indices aren't
|
|
33
|
-
* filtered (like libpng recommends)
|
|
34
|
-
*/
|
|
35
|
-
export declare function encodeRGBA(rgba: Uint8Array, width: number, height: number, level: number, text?: EncodeOptions['text']): Promise<Uint8Array>;
|
|
36
|
-
/**
|
|
37
|
-
* Decodes a PNG into 8-bit RGBA pixel data
|
|
38
|
-
* Supports all color types, bit depths, tRNS transparency and adam7 interlacing
|
|
39
|
-
* The orientation comes from the eXIf chunk, or, if there is none, from the Exif text ImageMagick wrote before eXIf
|
|
40
|
-
* existed ("Raw profile type exif") or from the XMP packet
|
|
41
|
-
* @param {Uint8Array} array The PNG data
|
|
42
|
-
* @return {{width: number, height: number, pixels: Uint8Array, orientation: number}}
|
|
43
|
-
*/
|
|
44
|
-
export declare function decode(array: Uint8Array): Promise<Decoded>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reduces RGBA pixel data to an indexed palette
|
|
3
|
-
* Pixels with alpha < 128 are mapped to a dedicated transparent index
|
|
4
|
-
* @param {Uint8Array} pixels RGBA pixel data
|
|
5
|
-
* @param {number} width Image width in pixels (needed for dithering)
|
|
6
|
-
* @param {{maxColors?: number, quality?: number}} [options] quality (1-100) scales the palette size exponentially (1 = 8 colors, 50 = 55, 90 and above = 256)
|
|
7
|
-
* @return {{palette: Uint8Array, indices: Uint8Array, transparentIndex: number}} palette is packed RGB, transparentIndex is -1 if unused
|
|
8
|
-
*/
|
|
9
|
-
export interface QuantizeOptions {
|
|
10
|
-
maxColors?: number;
|
|
11
|
-
quality?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface Quantized {
|
|
14
|
-
/** packed RGB */
|
|
15
|
-
palette: Uint8Array;
|
|
16
|
-
indices: Uint8Array;
|
|
17
|
-
/** -1 if no pixel is transparent */
|
|
18
|
-
transparentIndex: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Finds the color of the largest cluster among the opaque pixels that pass the filter
|
|
22
|
-
* @return packed RGB, or null if no pixel qualifies
|
|
23
|
-
*/
|
|
24
|
-
export declare function dominantColor(pixels: Uint8Array, include: (r: number, g: number, b: number) => boolean, clusters?: number): [number, number, number] | null;
|
|
25
|
-
export declare function quantize(pixels: Uint8Array, width: number, { maxColors, quality }?: QuantizeOptions): Quantized;
|
package/dist/codecs/tiff.d.ts
DELETED
package/dist/codecs/zlib.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* zlib deflate/inflate, derived from fflate (https://github.com/101arrowz/fflate)
|
|
3
|
-
* Copyright (c) 2020 Arjun Barrett, MIT License (see THIRD_PARTY_NOTICES.md)
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Compresses data into a zlib stream
|
|
7
|
-
* @param level compression level 0-9
|
|
8
|
-
*/
|
|
9
|
-
export declare function compress(data: Uint8Array, level: number): Uint8Array;
|
|
10
|
-
/**
|
|
11
|
-
* Decompresses a zlib stream into at most limit bytes
|
|
12
|
-
*/
|
|
13
|
-
export declare function decompress(data: Uint8Array, limit: number): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Compresses data into a zlib stream, with the runtime's native zlib when available
|
|
16
|
-
* @param level compression level 0-9
|
|
17
|
-
*/
|
|
18
|
-
export declare function compressAsync(data: Uint8Array, level: number): Promise<Uint8Array>;
|
|
19
|
-
/**
|
|
20
|
-
* Decompresses a zlib stream into at most limit bytes, using the runtime's native zlib when available
|
|
21
|
-
*/
|
|
22
|
-
export declare function decompressAsync(data: Uint8Array, limit: number): Promise<Uint8Array>;
|
package/dist/render/font.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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 {};
|
package/dist/render/svg.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string|Uint8Array} source
|
|
3
|
-
* @param {number} mode 1 = scale by size, 2 = fit width to size, 3 = fit height to size
|
|
4
|
-
* @param {number} size
|
|
5
|
-
* @return {{width: number, height: number, pixels: Uint8Array}}
|
|
6
|
-
*/
|
|
7
|
-
export declare function render(source: string | Uint8Array, mode: number, size: number): {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
pixels: Uint8Array;
|
|
11
|
-
};
|
package/dist/render/text.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* The Rasterizer class is translated from font-rs (https://github.com/raphlinus/font-rs)
|
|
3
|
-
* Copyright 2015 Google Inc., Apache License 2.0 (see THIRD_PARTY_NOTICES.md and licenses/Apache-2.0.txt)
|
|
4
|
-
*/
|
|
5
|
-
import { PathCommand } from './font.js';
|
|
6
|
-
export interface Layout {
|
|
7
|
-
maxWidth: number;
|
|
8
|
-
maxHeight: number;
|
|
9
|
-
wrapStyle: 'word' | 'char';
|
|
10
|
-
horizontalAlign: 'left' | 'center' | 'right';
|
|
11
|
-
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
12
|
-
wrapHardBreaks: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface GlyphBitmap {
|
|
15
|
-
data: Uint8Array;
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
/** offset from the pen position */
|
|
19
|
-
left: number;
|
|
20
|
-
/** offset above the baseline */
|
|
21
|
-
top: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Lays out and rasterizes text
|
|
25
|
-
* Lines start at ceil(ascender) and advance by ceil(ascender - descender + lineGap); glyphs are placed with
|
|
26
|
-
* subpixel precision using their advance widths and the font's kerning; the canvas spans from the origin to the
|
|
27
|
-
* furthest glyph edge
|
|
28
|
-
* @param {Uint8Array} data TrueType/OpenType font
|
|
29
|
-
* @param {number} size font size in pixels per em
|
|
30
|
-
* @param {string} text
|
|
31
|
-
* @param {Layout} layout
|
|
32
|
-
* @return {{width: number, height: number, coverage: Uint8Array}}
|
|
33
|
-
*/
|
|
34
|
-
export declare function render(data: Uint8Array, size: number, text: string, layout: Layout): {
|
|
35
|
-
width: number;
|
|
36
|
-
height: number;
|
|
37
|
-
coverage: Uint8Array;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Rasterizes a glyph outline into an 8-bit coverage bitmap
|
|
41
|
-
* @param {Array} path outline in font units (y up)
|
|
42
|
-
* @param {number} scale pixels per font unit
|
|
43
|
-
* @param {number} [offset=0] horizontal subpixel offset
|
|
44
|
-
* @return {{data: Uint8Array, width: number, height: number, left: number, top: number}|null}
|
|
45
|
-
* left/top position the bitmap relative to the pen position on the baseline (top is measured upwards)
|
|
46
|
-
*/
|
|
47
|
-
export declare function rasterizeGlyph(path: PathCommand[], scale: number, offset?: number): GlyphBitmap | null;
|
|
48
|
-
/**
|
|
49
|
-
* Signed area coverage rasterizer: every line segment adds its area to an accumulation buffer,
|
|
50
|
-
* a prefix sum over each row yields the coverage
|
|
51
|
-
*/
|
|
52
|
-
export declare class Rasterizer {
|
|
53
|
-
width: number;
|
|
54
|
-
height: number;
|
|
55
|
-
accumulation: Float32Array;
|
|
56
|
-
constructor(width: number, height: number);
|
|
57
|
-
line(x0: number, y0: number, x1: number, y1: number): void;
|
|
58
|
-
quad(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): void;
|
|
59
|
-
cubic(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
60
|
-
coverage(): Uint8Array;
|
|
61
|
-
}
|
package/dist/util/blur.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Blurs premultiplied RGBA float pixels in place
|
|
3
|
-
* @param sigma standard deviation of the gaussian in pixels
|
|
4
|
-
*/
|
|
5
|
-
export declare function gaussianBlur(pixels: Float32Array, width: number, height: number, sigma: number): void;
|
|
6
|
-
/**
|
|
7
|
-
* Converts 8-bit RGBA to premultiplied floats
|
|
8
|
-
*/
|
|
9
|
-
export declare function premultiply(rgba: Uint8ClampedArray): Float32Array;
|
|
10
|
-
/**
|
|
11
|
-
* Converts premultiplied floats back to 8-bit RGBA (the clamped output rounds)
|
|
12
|
-
*/
|
|
13
|
-
export declare function unpremultiply(pixels: Float32Array, out: Uint8ClampedArray): void;
|
package/dist/util/resample.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface Filter {
|
|
2
|
-
/** radius of the filter at scale 1 */
|
|
3
|
-
support: number;
|
|
4
|
-
weight: (x: number) => number;
|
|
5
|
-
}
|
|
6
|
-
export declare const BOX: Filter;
|
|
7
|
-
export declare const TRIANGLE: Filter;
|
|
8
|
-
export declare const CUBIC: Filter;
|
|
9
|
-
/**
|
|
10
|
-
* Resamples RGBA pixels with the given filter, in premultiplied alpha so transparent pixels don't bleed their color
|
|
11
|
-
*/
|
|
12
|
-
export declare function resample(src: Uint8ClampedArray, width: number, height: number, outWidth: number, outHeight: number, filter: Filter, out: Uint8ClampedArray): void;
|
package/dist/util/utf8.d.ts
DELETED
package/dist/version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.0";
|