Re: [whatwg] Proposal: toDataURL “image/png” compression control

On Wed, May 28, 2014 at 10:36 PM, Noel Gordon <noel.gordon@gmail.com> wrote:

> <canvas>.toDataURL supports an optional quality argument for the
> “image/jpeg” mime type to control image compression. Developers have no
> control over “image/png” compression.
>
> “image/png” is a lossless image compression format and the proposal is to
> allow developers some control over the compression process. For example, a
> developer might request maximum compression once their art work is complete
> to minimize the encoded image size for transmission or storage. Encoding
> speed might be more important while creating the work, and less compression
> (faster encoding) could be requested in that case.
>
> An optional toDataURL parameter on [0.0 ... 1.0], similar to the optional
> quality argument used for "image/jpeg", could be defined for “image/png” to
> control compression:
>
>    <canvas>.toDataURL(“image/png”, [compression-control-value]);
>
> The default value, and how the browser controls the image encoder to gain
> more compression with increasing values, would be internal implementation
> details of the browser.
>

This has been requested before. ie
http://lists.whatwg.org/pipermail/help-whatwg.org/2013-May/001209.html
The conclusion was that this can be accomplished using JavaScript. There
are JS libraries that can compress images and performance is very good
these days.

If you're worried about blocking the main thread, you can use workers to do
offline processing.

Received on Thursday, 29 May 2014 06:33:10 UTC