imagescript 1.3.1 → 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 (117) 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 -954
  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/wasm/bin/codecs.wasm +0 -0
  76. package/codecs/wasm/bin/simd.wasm +0 -0
  77. package/codecs/wasm/bundle/browser.js +0 -1
  78. package/codecs/wasm/index.js +0 -1
  79. package/codecs/wasm/index.mjs +0 -1
  80. package/png/README.md +0 -1
  81. package/png/node.js +0 -1137
  82. package/png/src/crc.mjs +0 -49
  83. package/png/src/mem.mjs +0 -24
  84. package/png/src/png.mjs +0 -254
  85. package/png/src/zlib.mjs +0 -618
  86. package/tsconfig.json +0 -21
  87. package/utils/mem.js +0 -26
  88. package/v2/codecs/magic.js +0 -25
  89. package/v2/framebuffer.d.ts +0 -67
  90. package/v2/framebuffer.js +0 -2352
  91. package/v2/framebuffer.mjs +0 -126
  92. package/v2/framebuffer.rs +0 -1264
  93. package/v2/index.d.ts +0 -84
  94. package/v2/index.js +0 -261
  95. package/v2/ops/blur.mjs +0 -303
  96. package/v2/ops/color.mjs +0 -277
  97. package/v2/ops/crop.mjs +0 -64
  98. package/v2/ops/fill.mjs +0 -33
  99. package/v2/ops/flip.mjs +0 -33
  100. package/v2/ops/index.mjs +0 -9
  101. package/v2/ops/iterator.mjs +0 -34
  102. package/v2/ops/overlay.mjs +0 -63
  103. package/v2/ops/resize.mjs +0 -166
  104. package/v2/ops/rotate.mjs +0 -117
  105. package/v2/util/mem.mjs +0 -24
  106. package/wasm/any/font.wasm +0 -0
  107. package/wasm/any/gif.wasm +0 -0
  108. package/wasm/any/jpeg.wasm +0 -0
  109. package/wasm/any/png.wasm +0 -0
  110. package/wasm/any/svg.wasm +0 -0
  111. package/wasm/any/tiff.wasm +0 -0
  112. package/wasm/node/font.js +0 -142
  113. package/wasm/node/gif.js +0 -76
  114. package/wasm/node/jpeg.js +0 -92
  115. package/wasm/node/png.js +0 -49
  116. package/wasm/node/svg.js +0 -56
  117. 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 {};