User agents must support PNG ("image/pngp1156
"). User agents may support other types. If the user agent does not support the requested type, it
must create the file using the PNG format.[PNG]p1162
User agents mustconvert the provided type to ASCII lowercasep63
before establishing if they support that type.
For image types that do not support an alpha channel, the serialised image must be the bitmap image composited onto a solid black background
using the source-over operator.
If the first argument inargumentsgives a type corresponding to one of the types given in the first column of the following table, and the user agent
supports that type, then the subsequent arguments, if any, must be treated as described in the second cell of that row.
Arguments for serialisation methods
The second argument, if it is a number in the range 0.0 to 1.0 inclusive, must be treated as the desired quality level. If it is not a number or is outside
that range, the user agent must use its default value, as if the argument had been omitted.
For the purposes of these rules, an argument is considered to be a number if it is converted to an IDL double value by the rules for handling
arguments of typeanyin the Web IDL specification.[WEBIDL]p1164
Other arguments must be ignored and must not cause the user agent to throw an exception. A future version of this specification will probably
define other parameters to be passed to these methods to allow authors to more carefully control compression settings, image metadata, etc.
18.104.22.168 Security withcanvasp583
This section is non-normative.
Information leakagecan occur if scripts from oneoriginp767
can access information (e.g. read pixels) from images from another origin (one that isn't
To mitigate this, bitmaps used withcanvasp583
objects are defined to have a flag indicating whether they are
. All bitmaps start with theirorigin-cleanp584
set to true. The flag is set to false when cross-origin images or fonts are used.
methods check the flag and will throw a"SecurityError"
rather than leak cross-origin data.
The value of theorigin-cleanp584
flag is propagated from a sourcecanvasp583
element's bitmap to a newImageBitmapp880
. Conversely, a destinationcanvasp583
element's bitmap will have itsorigin-cleanp584
flags set to false by
if the source image is anImageBitmapp880
object whose bitmap has itsorigin-cleanp584
flag set to false.
The flag can be reset in certain situations; for example, when changing the value of thewidthp584
content attribute of the
element to which aCanvasRenderingContext2Dp587
is bound, the bitmap is cleared and itsorigin-cleanp584
flag is reset.
When using anImageBitmapRenderingContextp642
, the value of theorigin-cleanp584
flag is propagated fromImageBitmapp880
they are transfered to thecanvasp583
4.13 Custom elements
This section is non-normative.
provide a way for authors to build their own fully-featured DOM elements. Although authors could always use non-standard
elements in their documents, with application-specific behaviour added after the fact by scripting or similar, such elements have historically been
For example, the value "image/pngp1156
" would mean to generate a PNG image, the value "image/jpegp1156
" would mean to
generate a JPEG image, and the value "image/svg+xmlp1156
" would mean to generate an SVG image (which would require that the
user agent track how the bitmap was generated, an unlikely, though potentially awesome, feature).