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.
Files changed (146) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +64 -26
  3. package/THIRD_PARTY_NOTICES.md +74 -0
  4. package/dist/codecs/crc.d.ts +9 -0
  5. package/dist/codecs/crc.js +29 -0
  6. package/dist/codecs/exif.d.ts +11 -0
  7. package/dist/codecs/exif.js +27 -0
  8. package/dist/codecs/gif.d.ts +44 -0
  9. package/dist/codecs/gif.js +401 -0
  10. package/dist/codecs/jpeg.d.ts +35 -0
  11. package/dist/codecs/jpeg.js +980 -0
  12. package/dist/codecs/png.d.ts +44 -0
  13. package/dist/codecs/png.js +442 -0
  14. package/dist/codecs/quantize.d.ts +25 -0
  15. package/dist/codecs/quantize.js +302 -0
  16. package/dist/codecs/tiff.d.ts +6 -0
  17. package/dist/codecs/tiff.js +546 -0
  18. package/dist/codecs/zlib.d.ts +22 -0
  19. package/dist/codecs/zlib.js +607 -0
  20. package/dist/frame.d.ts +57 -0
  21. package/dist/frame.js +65 -0
  22. package/dist/gif.d.ts +44 -0
  23. package/dist/gif.js +93 -0
  24. package/dist/image-type.d.ts +20 -0
  25. package/dist/image-type.js +49 -0
  26. package/dist/image.d.ts +521 -0
  27. package/dist/image.js +1118 -0
  28. package/dist/index.d.ts +19 -0
  29. package/dist/index.js +13 -0
  30. package/dist/package.json +1 -0
  31. package/dist/render/font.d.ts +63 -0
  32. package/dist/render/font.js +857 -0
  33. package/dist/render/svg.d.ts +11 -0
  34. package/dist/render/svg.js +1717 -0
  35. package/dist/render/text.d.ts +61 -0
  36. package/dist/render/text.js +317 -0
  37. package/dist/text-layout.d.ts +46 -0
  38. package/dist/text-layout.js +35 -0
  39. package/dist/util/blur.d.ts +13 -0
  40. package/dist/util/blur.js +146 -0
  41. package/dist/util/mem.d.ts +10 -0
  42. package/dist/util/mem.js +23 -0
  43. package/dist/util/resample.d.ts +12 -0
  44. package/dist/util/resample.js +99 -0
  45. package/dist/util/utf8.d.ts +5 -0
  46. package/dist/util/utf8.js +55 -0
  47. package/dist/version.d.ts +1 -0
  48. package/dist/version.js +1 -0
  49. package/licenses/Apache-2.0.txt +202 -0
  50. package/licenses/README.ijg +260 -0
  51. package/package.json +31 -7
  52. package/ImageScript.d.ts +0 -235
  53. package/ImageScript.js +0 -1669
  54. package/bench/_.mjs +0 -166
  55. package/bench/all.mjs +0 -4
  56. package/bench/blur.mjs +0 -59
  57. package/bench/flip.mjs +0 -63
  58. package/bench/overlay.mjs +0 -35
  59. package/bench/package.json +0 -7
  60. package/bench/readme.md +0 -64
  61. package/bench/resize.mjs +0 -52
  62. package/codecs/LICENSE +0 -21
  63. package/codecs/lib.d.ts +0 -50
  64. package/codecs/lib.js +0 -6
  65. package/codecs/lib.mjs +0 -1
  66. package/codecs/node/bin/arm64-darwin.node +0 -0
  67. package/codecs/node/bin/arm64-linux.node +0 -0
  68. package/codecs/node/bin/x64-darwin.node +0 -0
  69. package/codecs/node/bin/x64-linux.node +0 -0
  70. package/codecs/node/bin/x64-win32.node +0 -0
  71. package/codecs/node/index.js +0 -3
  72. package/codecs/node/index.mjs +0 -6
  73. package/codecs/package.json +0 -14
  74. package/codecs/readme.md +0 -38
  75. package/codecs/tests/gif.js +0 -0
  76. package/codecs/tests/jpeg.js +0 -0
  77. package/codecs/tests/png.js +0 -0
  78. package/codecs/tests/results/gif/1024.nis.gif +0 -0
  79. package/codecs/tests/results/gif/1024.skyra.gif +0 -0
  80. package/codecs/tests/results/gif/256.nis.gif +0 -0
  81. package/codecs/tests/results/gif/256.skyra.gif +0 -0
  82. package/codecs/tests/results/jpeg/256.jpegjs.jpeg +0 -0
  83. package/codecs/tests/results/jpeg/256.nis.jpeg +0 -0
  84. package/codecs/tests/results/jpeg/256.sharp.jpeg +0 -0
  85. package/codecs/tests/results/jpeg/512.jpegjs.jpeg +0 -0
  86. package/codecs/tests/results/jpeg/512.nis.jpeg +0 -0
  87. package/codecs/tests/results/jpeg/512.sharp.jpeg +0 -0
  88. package/codecs/tests/results/jpeg/64.jpegjs.jpeg +0 -0
  89. package/codecs/tests/results/jpeg/64.nis.jpeg +0 -0
  90. package/codecs/tests/results/jpeg/64.sharp.jpeg +0 -0
  91. package/codecs/tests/results/png/256.jis.png +0 -0
  92. package/codecs/tests/results/png/256.nis.png +0 -0
  93. package/codecs/tests/results/png/256.sharp.png +0 -0
  94. package/codecs/tests/results/png/256.upng.png +0 -0
  95. package/codecs/tests/results/png/512.jis.png +0 -0
  96. package/codecs/tests/results/png/512.nis.png +0 -0
  97. package/codecs/tests/results/png/512.sharp.png +0 -0
  98. package/codecs/tests/results/png/512.upng.png +0 -0
  99. package/codecs/tests/results/png/64.jis.png +0 -0
  100. package/codecs/tests/results/png/64.nis.png +0 -0
  101. package/codecs/tests/results/png/64.sharp.png +0 -0
  102. package/codecs/tests/results/png/64.upng.png +0 -0
  103. package/codecs/tests/webp.js +0 -0
  104. package/codecs/wasm/bin/codecs.wasm +0 -0
  105. package/codecs/wasm/bin/simd.wasm +0 -0
  106. package/codecs/wasm/bundle/browser.js +0 -1
  107. package/codecs/wasm/index.js +0 -1
  108. package/codecs/wasm/index.mjs +0 -1
  109. package/png/README.md +0 -1
  110. package/png/node.js +0 -1137
  111. package/png/src/crc.mjs +0 -49
  112. package/png/src/mem.mjs +0 -24
  113. package/png/src/png.mjs +0 -254
  114. package/png/src/zlib.mjs +0 -618
  115. package/tsconfig.json +0 -21
  116. package/utils/mem.js +0 -26
  117. package/v2/codecs/magic.js +0 -25
  118. package/v2/framebuffer.d.ts +0 -67
  119. package/v2/framebuffer.js +0 -2352
  120. package/v2/framebuffer.mjs +0 -126
  121. package/v2/framebuffer.rs +0 -1264
  122. package/v2/index.d.ts +0 -84
  123. package/v2/index.js +0 -261
  124. package/v2/ops/blur.mjs +0 -303
  125. package/v2/ops/color.mjs +0 -277
  126. package/v2/ops/crop.mjs +0 -64
  127. package/v2/ops/fill.mjs +0 -33
  128. package/v2/ops/flip.mjs +0 -33
  129. package/v2/ops/index.mjs +0 -9
  130. package/v2/ops/iterator.mjs +0 -34
  131. package/v2/ops/overlay.mjs +0 -63
  132. package/v2/ops/resize.mjs +0 -166
  133. package/v2/ops/rotate.mjs +0 -117
  134. package/v2/util/mem.mjs +0 -24
  135. package/wasm/any/font.wasm +0 -0
  136. package/wasm/any/gif.wasm +0 -0
  137. package/wasm/any/jpeg.wasm +0 -0
  138. package/wasm/any/png.wasm +0 -0
  139. package/wasm/any/svg.wasm +0 -0
  140. package/wasm/any/tiff.wasm +0 -0
  141. package/wasm/node/font.js +0 -142
  142. package/wasm/node/gif.js +0 -76
  143. package/wasm/node/jpeg.js +0 -92
  144. package/wasm/node/png.js +0 -49
  145. package/wasm/node/svg.js +0 -56
  146. package/wasm/node/tiff.js +0 -47
@@ -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 {};