I'm trying with FileSaver.js ( https://github.com/eligrey/FileSaver.js/ )
When I save an image of type jpg, the save as dialog displaying in Firefox gives incorrect value at Save as type dropdown (It says "PNG Image ( .jpg), but what I expect is JPEG Image ( .jpg)).
Could anyone tell me how to fix this?
Finally, I found out the reason for this issue.
I use canvas-toblob javascript library to convert a canvas to blob. But Firefox has internal implementation for toblob method, so the same method in canvas-toblob.js is never called.
I modify canvas-toblob.js so that Firefox will use the method in this library. This solved my issue
if (HTMLCanvasElement) { canvas_proto.toBlob = function(callback, type /*, ...args*/) { if (!type) { type = "image/png"; } if (this.msToBlob && /^\\s*image\\/png\\s*(?:$|;)/i.test(type)) { callback(this.msToBlob()); return; }
您需要为type参数指定image / jpeg。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.