@catlabtech/webcvt-image-canvas
v0.1.0
Published
Browser-native image conversion backend for webcvt — PNG, JPG, WebP, BMP, ICO via Canvas API
Readme
@catlabtech/webcvt-image-canvas
Browser-native image conversion backend for webcvt.
Converts between PNG, JPG, WebP, BMP, and ICO using nothing but the browser's Canvas API (createImageBitmap + OffscreenCanvas + convertToBlob). No WASM. No external codecs.
Supported conversions
| Input | Output | |-------|--------| | PNG, JPG/JPEG, WebP, BMP, ICO, GIF (decode only) | PNG, JPG/JPEG, WebP, BMP, ICO |
GIF can be decoded as input but cannot be produced as output (the Canvas API does not encode GIF).
Usage
import { CanvasBackend } from '@catlabtech/webcvt-image-canvas';
import { defaultRegistry } from '@catlabtech/webcvt-core';
// Register once
defaultRegistry.register(new CanvasBackend());Implementation references
- ICO file format: https://en.wikipedia.org/wiki/ICO_(file_format)
- BMP file format: https://en.wikipedia.org/wiki/BMP_file_format (BITMAPINFOHEADER, BI_RGB)
- OffscreenCanvas API: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas
- createImageBitmap: https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap
License
MIT
