-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Some discussion in #743, but in essence there should be a non-streaming API for all formats with all config options (e.g. quality, PNG filter).
toBuffer(cb: function, mimeType?: string, quality?: number) would parallel toBlob.
toBuffer(cb, "image/jpeg", quality: number);
toBuffer(cb, "image/png", compressionLevel: number);
// accommodate non-standard options:
toBuffer(cb, "image/png", {compressionLevel?: number, filter?: number, palette?: Uint8ClampedArray, backgroundIndex?: number});
toBuffer(cb, "image/svg"); // throws if not an SVG canvas
toBuffer(cb, "raw"); // Maybe? No need for this to use a callback as it's just a memcpy.
toBuffer(cb, "image/gif"); // maybe in the futureAlternatively, @adamhooper proposed separate toPNG/toJPEG functions.
Should there be sync versions that return a value instead of accepting a callback?
See also #934 about cleaning up the PNG filter API.
I can work on this sometime soon. Feedback welcome.