W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2014

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

From: Rik Cabanier <cabanier@gmail.com>
Date: Wed, 28 May 2014 23:32:46 -0700
Message-ID: <CAGN7qDCV=OY29GFtPHrX=X1S8dk7CPhPR3N8uCWviTWDPReM8Q@mail.gmail.com>
To: Noel Gordon <noel.gordon@gmail.com>
Cc: whatwg <whatwg@lists.whatwg.org>
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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:28 UTC