Closed
Bug 693539
Opened 14 years ago
Closed 14 years ago
Canvas .toDataURL should throw when invalid mimetype specified.
Categories
(Core :: Graphics: Canvas2D, defect)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
INVALID
People
(Reporter: Dolske, Unassigned)
Details
Over in bug 693099 we added support for saving a frame of a HTML5 <video> as a JPEG. Except what we were saving wasn't actually a JPEG, it was actually a PNG. Oops.
The culprit was this call:
canvas.toDataURL("image/jpg", "")
Spot the flaw? ... Yep, should be "image/jpeg".
Canvas should throw when given an invalid mimetype to help avoid this kind of problem. We might also want to consider allowing "image/jpg" for JPEG, though I expect there are MIME purists who will have words to say about that. ;-)
Comment 1•14 years ago
|
||
User agents supposed to ignore unknown types.
http://dev.w3.org/html5/spec/the-canvas-element.html#a-serialization-of-the-image-as-a-file
> User agents must support PNG ("image/png"). 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]
Comment 2•14 years ago
|
||
Invalid as filed. A console warning could be added, of course.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Comment 3•14 years ago
|
||
Would it still be useful to modify saveImageURL (http://mxr.mozilla.org/mozilla-central/source/toolkit/content/contentAreaUtils.js#145) such that if Canvas .toDataURL has fallen back to PNG, the filename passed from nsContextMenu.js gets adjusted from JPG to PNG?
| Reporter | ||
Comment 4•14 years ago
|
||
Yuck, that seems like a rather unfortunate part of the spec. Sigh.
You need to log in
before you can comment on or make changes to this bug.
Description
•