Skip to content

Instantly share code, notes, and snippets.

@lucprincen
Last active December 21, 2020 03:10
Show Gist options
  • Save lucprincen/5797028 to your computer and use it in GitHub Desktop.
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.
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