chore: resize 100x100 to 28x28

This commit is contained in:
Marcin Czerniak 2021-06-21 02:04:01 +02:00
parent aa3e0b59c1
commit 6c07c7ea1e

View File

@ -12,8 +12,25 @@ class OrdersView {
[...document.querySelectorAll('.orders-window .canvases canvas')].map((canv, index) => {
return new Promise((resolve, reject) => {
canv.toBlob(blob => {
formData.append(`file-${index}`, blob,`file-${index}.png`);
resolve();
let blobUrl = URL.createObjectURL(blob);
const img = new Image();
img.src = blobUrl;
img.onload = () => {
const canvas = document.createElement('canvas');
canvas.width = 28;
canvas.height = 28;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, 28, 28);
canvas.toBlob((blob) => {
// blobUrl = URL.createObjectURL(blob);
formData.append(`file-${index}`, blob,`file-${index}.png`);
resolve();
}, 'image/png');
}
});
});
})