forked from cory/tildefriends
lit 2.5.0, and cap image max dimentions.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4074 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
51
apps/cory/ssblit/lit-all.min.js
vendored
51
apps/cory/ssblit/lit-all.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -66,10 +66,13 @@ class TfComposeElement extends LitElement {
|
||||
let img = new Image();
|
||||
img.onload = function() {
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
let width_scale = Math.min(img.width, 1024) / img.width;
|
||||
let height_scale = Math.min(img.height, 1024) / img.height;
|
||||
let scale = Math.min(width_scale, height_scale);
|
||||
canvas.width = img.width * scale;
|
||||
canvas.height = img.height * scale;
|
||||
let context = canvas.getContext('2d');
|
||||
context.drawImage(img, 0, 0);
|
||||
context.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
let data_url = canvas.toDataURL('image/webp');
|
||||
let result = atob(data_url.split(',')[1]).split('').map(x => x.charCodeAt(0));
|
||||
resolve(result);
|
||||
|
Reference in New Issue
Block a user