[html5] HTML5 canvas.toDataURL suggestions

Sigurd Lerstad sigurd.lerstad at gmail.com
Sat May 18 02:49:53 PDT 2013


I suggest improving / making more flexible the canvas.toDataURL API

 

The API is currently called with a second quality argument for the JPEG and
WebP formats, and no second argument for the PNG format:

 

toDataURL(type, quality);           // JPEG and WebP

toDataURL(type);           // PNG

 

I suggest the following possibilities as well:

 

toDataURL("image/jpeg", {

             quality: 0..1,

             grayscale: true/false,     // since the JPEG format also
supports grayscale images at smaller files sizes

             progressive: true/false

}

 

For the WebP format, as far as I can see, Chrome currently doesn't create an
alpha channel.

Also, the possibility to create lossless WebP would be nice, I'm not sure if
specifying a value of 1 for quality, accomplishes this.

 

toDataURL("image/webp", {

             quality: 0..1,

             alpha: true/false,

             alphaQuality: 0..1 (same as quality if omitted)

             .

}

 

For the PNG format:

 

toDataURL("image/png", {

             interlaced: true/false,

             grayscale: true/false,

             alpha: true/false,

}

 

Some means of creating 8bit color indexed PNG would also be nice.

 

--

Sigurd Lerstad

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/help-whatwg.org/attachments/20130518/d1c8f4f0/attachment-0001.htm>


More information about the Help mailing list