emf-converter 4.19.0 → 4.20.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/dist/index.d.mts CHANGED
@@ -210,6 +210,29 @@ interface EmfConvertOptions {
210
210
  */
211
211
  fontSmoothing?: 'cleartype' | 'gray' | 'mono';
212
212
  }
213
+ /**
214
+ * Options for {@link convertMetafileToJpegDataUrl}: every
215
+ * {@link EmfConvertOptions} field plus the JPEG encoding settings.
216
+ */
217
+ interface JpegConvertOptions extends EmfConvertOptions {
218
+ /**
219
+ * JPEG quality from 0 to 1, as for `canvas.toDataURL('image/jpeg', quality)`.
220
+ * Default 0.92.
221
+ */
222
+ quality?: number;
223
+ /**
224
+ * Colour the transparent background and translucent pixels are
225
+ * composited over, as `#rgb` or `#rrggbb` (JPEG has no alpha channel).
226
+ * Default `'#ffffff'`.
227
+ */
228
+ background?: string;
229
+ /**
230
+ * `true` averages colour over 2 x 2 pixels (4:2:0) for a smaller file.
231
+ * Default `false`: full-resolution colour (4:4:4), which keeps coloured
232
+ * lines and text free of colour fringes.
233
+ */
234
+ chromaSubsampling?: boolean;
235
+ }
213
236
  /**
214
237
  * Options for the SVG outputs ({@link convertMetafileToSvg} and friends).
215
238
  * `maxWidth`/`maxHeight`/`dpiScale`/`maxCanvasDimension` set the SVG's
@@ -291,6 +314,21 @@ interface SvgConvertOptions extends EmfConvertOptions {
291
314
  * @returns A `data:image/png;base64,...` string, or `null` on failure.
292
315
  */
293
316
  declare function convertMetafileToDataUrl(buffer: ArrayBuffer, options?: EmfConvertOptions, recursionDepth?: number): Promise<string | null>;
317
+ /**
318
+ * Converts an EMF or WMF buffer (format auto-detected) to a JPEG data URL.
319
+ *
320
+ * The drawing is rendered exactly as for {@link convertMetafileToDataUrl}
321
+ * (same options, same backends, same `null` cases) and encoded by the
322
+ * bundled baseline JPEG encoder, so the bytes do not depend on the canvas
323
+ * backend. JPEG has no transparency: the metafile's transparent background
324
+ * and any translucent pixels are composited over
325
+ * {@link JpegConvertOptions.background} (white by default).
326
+ *
327
+ * @param buffer - The raw EMF or WMF file bytes.
328
+ * @param options - Optional {@link JpegConvertOptions}.
329
+ * @returns A `data:image/jpeg;base64,...` string, or `null` on failure.
330
+ */
331
+ declare function convertMetafileToJpegDataUrl(buffer: ArrayBuffer, options?: JpegConvertOptions): Promise<string | null>;
294
332
 
295
333
  /**
296
334
  * Converts an EMF or WMF buffer (format auto-detected) into an SVG document
@@ -381,4 +419,4 @@ interface LoadSystemFontsOptions {
381
419
  */
382
420
  declare function loadSystemFonts(options?: LoadSystemFontsOptions): Promise<Uint8Array[]>;
383
421
 
384
- export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
422
+ export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type JpegConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToJpegDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
package/dist/index.d.ts CHANGED
@@ -210,6 +210,29 @@ interface EmfConvertOptions {
210
210
  */
211
211
  fontSmoothing?: 'cleartype' | 'gray' | 'mono';
212
212
  }
213
+ /**
214
+ * Options for {@link convertMetafileToJpegDataUrl}: every
215
+ * {@link EmfConvertOptions} field plus the JPEG encoding settings.
216
+ */
217
+ interface JpegConvertOptions extends EmfConvertOptions {
218
+ /**
219
+ * JPEG quality from 0 to 1, as for `canvas.toDataURL('image/jpeg', quality)`.
220
+ * Default 0.92.
221
+ */
222
+ quality?: number;
223
+ /**
224
+ * Colour the transparent background and translucent pixels are
225
+ * composited over, as `#rgb` or `#rrggbb` (JPEG has no alpha channel).
226
+ * Default `'#ffffff'`.
227
+ */
228
+ background?: string;
229
+ /**
230
+ * `true` averages colour over 2 x 2 pixels (4:2:0) for a smaller file.
231
+ * Default `false`: full-resolution colour (4:4:4), which keeps coloured
232
+ * lines and text free of colour fringes.
233
+ */
234
+ chromaSubsampling?: boolean;
235
+ }
213
236
  /**
214
237
  * Options for the SVG outputs ({@link convertMetafileToSvg} and friends).
215
238
  * `maxWidth`/`maxHeight`/`dpiScale`/`maxCanvasDimension` set the SVG's
@@ -291,6 +314,21 @@ interface SvgConvertOptions extends EmfConvertOptions {
291
314
  * @returns A `data:image/png;base64,...` string, or `null` on failure.
292
315
  */
293
316
  declare function convertMetafileToDataUrl(buffer: ArrayBuffer, options?: EmfConvertOptions, recursionDepth?: number): Promise<string | null>;
317
+ /**
318
+ * Converts an EMF or WMF buffer (format auto-detected) to a JPEG data URL.
319
+ *
320
+ * The drawing is rendered exactly as for {@link convertMetafileToDataUrl}
321
+ * (same options, same backends, same `null` cases) and encoded by the
322
+ * bundled baseline JPEG encoder, so the bytes do not depend on the canvas
323
+ * backend. JPEG has no transparency: the metafile's transparent background
324
+ * and any translucent pixels are composited over
325
+ * {@link JpegConvertOptions.background} (white by default).
326
+ *
327
+ * @param buffer - The raw EMF or WMF file bytes.
328
+ * @param options - Optional {@link JpegConvertOptions}.
329
+ * @returns A `data:image/jpeg;base64,...` string, or `null` on failure.
330
+ */
331
+ declare function convertMetafileToJpegDataUrl(buffer: ArrayBuffer, options?: JpegConvertOptions): Promise<string | null>;
294
332
 
295
333
  /**
296
334
  * Converts an EMF or WMF buffer (format auto-detected) into an SVG document
@@ -381,4 +419,4 @@ interface LoadSystemFontsOptions {
381
419
  */
382
420
  declare function loadSystemFonts(options?: LoadSystemFontsOptions): Promise<Uint8Array[]>;
383
421
 
384
- export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
422
+ export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type JpegConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToJpegDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };