Last active
December 21, 2020 03:10
-
-
Save lucprincen/5797028 to your computer and use it in GitHub Desktop.
Save a copy of the canvas as a thumnail. Requires EaselJS and returns a base64 string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function saveCanvasThumbnail( scale ){ | |
| if( scale === undefined ) scale = .3; | |
| var canvas = getElementById( 'canvas' ); | |
| var bitmap = new createjs.Bitmap( canvas ); | |
| bitmap.cache( 0, 0, canvas.width, canvas.height, scale ); | |
| var base64 = bitmap.getCacheDataURL(); | |
| return base64; | |
| } | |
| var thumbnail_data = saveCanvasThumbnail( .5 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment