W3C home > Mailing lists > Public > public-html@w3.org > June 2008

<canvas> JPEG quality

From: Anne van Kesteren <annevk@opera.com>
Date: Thu, 05 Jun 2008 17:04:45 +0200
To: "HTML WG" <public-html@w3.org>
Message-ID: <op.ub96t7hh64w2qv@annevk-t60.oslo.opera.com>

At Opera we're planning on adding support to <canvas> for JPEG as export  
format. To make the file size reasonable there needs to be a way to set  
the quality level of the JPEG. Wikipedia has a nice example of why that  


One simple solution to this which is reasonably consistent with the rest  
of the <canvas> API is to add a jpegQuality DOM attribute to the <canvas>  
element which takes an integer in the range 0-1 (similar to globalAlpha).  
The default value could maybe be 0.75 as that usually gives reasonable  
looking images with a much smaller size than 1.0.

This attribute only affects toDataURL() and only when the first argument  
is not omitted and case-insensitively matches "image/jpeg".

Anne van Kesteren
Received on Thursday, 5 June 2008 15:05:11 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:34 UTC