简体   繁体   中英

Capture html canvas not as a dataURL

Is there a way to capture an html canvas's content not as a data url as in the example below?

Capture HTML Canvas as gif/jpg/png/pdf?

The reason I want to do this is I want to convert a canvas's content into a jpeg and then convert the jpeg into a file type to use with the plupload library. The only solution I have been able to find so far is to go from the dataURL to a blob using BlobBuilder() then to a file.

https://developer.mozilla.org/en-US/docs/Web/API/BlobBuilder

The BlobBuilder api is not very robust and has been rendered obsolete. Can anyone think of a better way to do this. Or a better way to convert a dataURL to a jpeg using javascript.

You want .jpg?

Just use the .toDataURL option to create a .jpg instead of the default .png

myCanvas.toDataURL( "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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM