2

It is said on HTML Canvas Element Interface page of Gecko DOM Reference, that:

If the requested type is image/jpeg, then the second argument, if it is between 0.0 and 1.0, is treated as indicating image quality; if the second argument is anything else, the default value for image quality is used. Other arguments are ignored.

But on practice I get: Security error" code: "1000.

Is it something that is not yet supported? Or why it might be happening? Any insightful advice or explanation might be helpful.

UPDATE:

I use newest File API to load local image file into memory first, scale it with the canvas and then export - with custom quality.

jayarjo
  • 16,124
  • 24
  • 94
  • 138
  • possible duplicate of [Why does canvas.toDataURL() throw a security exception?](http://stackoverflow.com/questions/2390232/why-does-canvas-todataurl-throw-a-security-exception) – Phrogz Jan 04 '11 at 15:19
  • See the duplicate question for the reason you are getting this security error. (If you haven't used `drawImage` and tainted your canvas, then I am wrong.) – Phrogz Jan 04 '11 at 15:20
  • Well... I saw that question too, but I wasn't sure if the case is same. I updated question. What you think? – jayarjo Jan 04 '11 at 15:37
  • But are you actually saying that the second param works for you in other scenarios? toDataUrl() works fine, until I add that second, quality setting. – jayarjo Jan 04 '11 at 15:40
  • @jayarjo Perhaps I am mistaken. To be absolutely clear: you are telling me that `canvas.toDataUrl('image/jpeg')` works (gives you a valid data URL) but `canvas.toDataUrl('image/jpeg',0.2)` throws the security exception? And this is the case even if you don't use any `drawImage()` calls whatsover? If so, it would be helpful if you could a) create a pared-down test example showing this, and b) clarified on what OS/browser/version you are seeting this problem. – Phrogz Jan 04 '11 at 16:46
  • Well... I use drawImage, how do I put image on canvas otherwise? But yes - canvas.toDataUrl('image/jpeg') works just fine. canvas.toDataUrl('image/jpeg',0.2) throws that error. It comes up on Windows and Mac, browser - FF 3.6.13. I can come up with an example, if you find it useful. – jayarjo Jan 05 '11 at 07:56

1 Answers1

3

It's a known bug.

Nickolay
  • 31,095
  • 13
  • 107
  • 185
  • 1
    Nice find. You can also see it failing the test here: http://philip.html5.org/tests/canvas/suite/tests/results.html#toDataURL.jpeg.quality.basic – Phrogz Jan 06 '11 at 22:01