This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11431 - should mention that .toDataURL() for image/jpeg acts as if the image was composited against black
Summary: should mention that .toDataURL() for image/jpeg acts as if the image was comp...
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-30 01:11 UTC by contributor
Modified: 2011-09-29 08:16 UTC (History)
7 users (show)

See Also:


Attachments

Description contributor 2010-11-30 01:11:46 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/complete.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#the-canvas-element

Comment:
should mention that .toDataURL() for image/jpeg acts as if the image was
composited against black

Posted from: 76.102.14.57
Comment 1 Ian 'Hixie' Hickson 2010-11-30 01:20:12 UTC
Actually mozilla and safari apparently don't do that, they instead unpremultiply the colours. Either way, this needs speccing.

Philip, I'm told you have tests for this that may not match implementations? Can you elaborate? Specifically, this one: http://philip.html5.org/tests/canvas/suite/tests/toDataURL.jpeg.alpha.html
Comment 2 Philip Taylor 2010-11-30 11:16:05 UTC
The spec already says:

  "For image types that do not support an alpha channel, the image must be composited onto a solid black background using the source-over operator, and the resulting image must be the one used to create the data: URL."

so I think it's clear on what's required (which is what that test tests).
Comment 3 Ian 'Hixie' Hickson 2010-12-01 00:31:44 UTC
So it does.

This doesn't seem to match what WebKit and Gecko do. Should we change the spec?
Comment 4 Philip Taylor 2010-12-04 23:48:47 UTC
Trying http://philip.html5.org/demos/canvas/jpeg-alpha.html with some variously old browsers:

Firefox (3.6): returns (r, g, b, 1).
Opera (10.60): returns (r, g, b, 1).
IE9 (some not-quite-latest preview): blends with black.
Safari (4.03 Win): blends with white.
Chrome (8.0 Win): doesn't support JPEG.

Doesn't look like there's really any convergence on one behaviour, so I'd guess the spec should define whatever seems the most sensible behaviour and then hope they converge in that direction.

(I don't know what's really the most sensible behaviour, but what the spec says sounds plausible to me.)
Comment 5 Noel Gordon 2010-12-15 07:23:17 UTC
(In reply to comment #4)

My results running http://philip.html5.org/demos/canvas/jpeg-alpha.html

Firefox 3.6.12 win32
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,59,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,59,255,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)

Chrome 10 dev win32
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,61,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,61,255,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)

Safari 5.0.2 win32
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,62,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,61,255,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(1,61,255,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(255,255,255,1)  <-- bug composites on white
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(255,255,255,1)  

Opera 10.63 Win32
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,64,253,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,64,253,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,63,252,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,63,252,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,56,244,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,56,244,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)

For alpha != 0.0
 results are the same neglecting rounding effects.
For alpha == 0.0
 composites on black (except safari, that is a safari bug).


Philip, can you add your full results for IE9?
Comment 6 Noel Gordon 2010-12-15 23:40:10 UTC
No worries, mike computed the results for me.

IE9 9.0.7930.16406 beta
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,32,127,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,6,25,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(0,32,127,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,6,25,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
Comment 7 Noel Gordon 2010-12-20 07:38:59 UTC
I've posted a webkit patch to make chromium conform with the standard for
review https://bugs.webkit.org/attachment.cgi?id=76964&action=prettypatch

Chrome 10 dev Win32 + above patch
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,1.0); format: image/jpeg; output: rgba(0,63,255,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(1,31,127,1)
 Input: rgba(0,63,255,0.5); format: image/jpeg; output: rgba(1,31,127,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,6,25,1)
 Input: rgba(0,63,255,0.1); format: image/jpeg; output: rgba(0,6,25,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
 Input: rgba(0,63,255,0.0); format: image/jpeg; output: rgba(0,0,0,1)
Comment 8 Ian 'Hixie' Hickson 2011-01-11 19:38:35 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale:

Based on the above, I'm going to reject this bug and leave it as is. Please do not hesitate to reopen it if I am mistaken in doing this.
Comment 10 Michael[tm] Smith 2011-08-04 05:17:23 UTC
mass-move component to LC1
Comment 11 Noel Gordon 2011-09-29 08:16:44 UTC
Safari (webkit nightly) and Chromium Mac now conform after change
http://trac.webkit.org/changeset/96000