codecs.d.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. interface DecodeModule extends EmscriptenWasm.Module {
  4. decode: (data: Uint8Array) => ImageData;
  5. }
  6. export interface ResizeOptions {
  7. width?: number;
  8. height?: number;
  9. method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3';
  10. premultiply: boolean;
  11. linearRGB: boolean;
  12. }
  13. export interface RotateOptions {
  14. numRotations: number;
  15. }
  16. import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc';
  17. import type { WebPModule as WebPEncodeModule } from './webp/webp_enc';
  18. import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc';
  19. import ImageData from './image_data';
  20. export declare const preprocessors: {
  21. readonly resize: {
  22. readonly name: "Resize";
  23. readonly description: "Resize the image before compressing";
  24. readonly instantiate: () => Promise<(buffer: Uint8Array, input_width: number, input_height: number, { width, height, method, premultiply, linearRGB }: ResizeOptions) => ImageData>;
  25. readonly defaultOptions: {
  26. readonly method: "lanczos3";
  27. readonly fitMethod: "stretch";
  28. readonly premultiply: true;
  29. readonly linearRGB: true;
  30. };
  31. };
  32. readonly rotate: {
  33. readonly name: "Rotate";
  34. readonly description: "Rotate image";
  35. readonly instantiate: () => Promise<(buffer: Uint8Array, width: number, height: number, { numRotations }: RotateOptions) => Promise<ImageData>>;
  36. readonly defaultOptions: {
  37. readonly numRotations: 0;
  38. };
  39. };
  40. };
  41. export declare const codecs: {
  42. readonly mozjpeg: {
  43. readonly name: "MozJPEG";
  44. readonly extension: "jpg";
  45. readonly detectors: readonly [RegExp];
  46. readonly dec: () => Promise<DecodeModule>;
  47. readonly enc: () => Promise<MozJPEGEncodeModule>;
  48. readonly defaultEncoderOptions: {
  49. readonly quality: 75;
  50. readonly baseline: false;
  51. readonly arithmetic: false;
  52. readonly progressive: true;
  53. readonly optimize_coding: true;
  54. readonly smoothing: 0;
  55. readonly color_space: 3;
  56. readonly quant_table: 3;
  57. readonly trellis_multipass: false;
  58. readonly trellis_opt_zero: false;
  59. readonly trellis_opt_table: false;
  60. readonly trellis_loops: 1;
  61. readonly auto_subsample: true;
  62. readonly chroma_subsample: 2;
  63. readonly separate_chroma_quality: false;
  64. readonly chroma_quality: 75;
  65. };
  66. readonly autoOptimize: {
  67. readonly option: "quality";
  68. readonly min: 0;
  69. readonly max: 100;
  70. };
  71. };
  72. readonly webp: {
  73. readonly name: "WebP";
  74. readonly extension: "webp";
  75. readonly detectors: readonly [RegExp];
  76. readonly dec: () => Promise<DecodeModule>;
  77. readonly enc: () => Promise<WebPEncodeModule>;
  78. readonly defaultEncoderOptions: {
  79. readonly quality: 75;
  80. readonly target_size: 0;
  81. readonly target_PSNR: 0;
  82. readonly method: 4;
  83. readonly sns_strength: 50;
  84. readonly filter_strength: 60;
  85. readonly filter_sharpness: 0;
  86. readonly filter_type: 1;
  87. readonly partitions: 0;
  88. readonly segments: 4;
  89. readonly pass: 1;
  90. readonly show_compressed: 0;
  91. readonly preprocessing: 0;
  92. readonly autofilter: 0;
  93. readonly partition_limit: 0;
  94. readonly alpha_compression: 1;
  95. readonly alpha_filtering: 1;
  96. readonly alpha_quality: 100;
  97. readonly lossless: 0;
  98. readonly exact: 0;
  99. readonly image_hint: 0;
  100. readonly emulate_jpeg_size: 0;
  101. readonly thread_level: 0;
  102. readonly low_memory: 0;
  103. readonly near_lossless: 100;
  104. readonly use_delta_palette: 0;
  105. readonly use_sharp_yuv: 0;
  106. };
  107. readonly autoOptimize: {
  108. readonly option: "quality";
  109. readonly min: 0;
  110. readonly max: 100;
  111. };
  112. };
  113. readonly avif: {
  114. readonly name: "AVIF";
  115. readonly extension: "avif";
  116. readonly detectors: readonly [RegExp];
  117. readonly dec: () => Promise<DecodeModule>;
  118. readonly enc: () => Promise<AVIFEncodeModule>;
  119. readonly defaultEncoderOptions: {
  120. readonly cqLevel: 33;
  121. readonly cqAlphaLevel: -1;
  122. readonly denoiseLevel: 0;
  123. readonly tileColsLog2: 0;
  124. readonly tileRowsLog2: 0;
  125. readonly speed: 6;
  126. readonly subsample: 1;
  127. readonly chromaDeltaQ: false;
  128. readonly sharpness: 0;
  129. readonly tune: 0;
  130. };
  131. readonly autoOptimize: {
  132. readonly option: "cqLevel";
  133. readonly min: 62;
  134. readonly max: 0;
  135. };
  136. };
  137. readonly oxipng: {
  138. readonly name: "OxiPNG";
  139. readonly extension: "png";
  140. readonly detectors: readonly [RegExp];
  141. readonly dec: () => Promise<{
  142. decode: (buffer: Buffer | Uint8Array) => any;
  143. }>;
  144. readonly enc: () => Promise<{
  145. encode: (buffer: Uint8ClampedArray | ArrayBuffer, width: number, height: number, opts: {
  146. level: number;
  147. }) => any;
  148. }>;
  149. readonly defaultEncoderOptions: {
  150. readonly level: 2;
  151. };
  152. readonly autoOptimize: {
  153. readonly option: "level";
  154. readonly min: 6;
  155. readonly max: 1;
  156. };
  157. };
  158. };
  159. export {};