Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support toBuffer(cb, mimeType, quality)? #982

Closed
zbjornson opened this issue Aug 31, 2017 · 1 comment
Closed

Support toBuffer(cb, mimeType, quality)? #982

zbjornson opened this issue Aug 31, 2017 · 1 comment
Labels

Comments

@zbjornson
Copy link
Collaborator

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 future

Alternatively, @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.

@jimmywarting
Copy link
Contributor

Can we depend on fetch-blob to make canvas.toBlob function in nodejs too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants