better downscale
This commit is contained in:
parent
8cdc26ec66
commit
13b3430f51
2 changed files with 12 additions and 4 deletions
|
@ -802,9 +802,13 @@ async function bytesToImage(bytes) {
|
|||
}
|
||||
|
||||
function resize(image) {
|
||||
while (Math.min(image.width, image.height) >= 2*artSize) {
|
||||
let tmp = node("canvas", {width:image.width/2, height:image.height/2});
|
||||
tmp.getContext("2d").drawImage(image, 0, 0, tmp.width, tmp.height);
|
||||
image = tmp;
|
||||
}
|
||||
const canvas = node("canvas", {width:artSize, height:artSize});
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
canvas.getContext("2d").drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,13 @@ async function bytesToImage(bytes) {
|
|||
}
|
||||
|
||||
function resize(image) {
|
||||
while (Math.min(image.width, image.height) >= 2*conf.artSize) {
|
||||
let tmp = html.node("canvas", {width:image.width/2, height:image.height/2});
|
||||
tmp.getContext("2d").drawImage(image, 0, 0, tmp.width, tmp.height);
|
||||
image = tmp;
|
||||
}
|
||||
const canvas = html.node("canvas", {width:conf.artSize, height:conf.artSize});
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
canvas.getContext("2d").drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue