瞎改
This commit is contained in:
@@ -2208,8 +2208,13 @@ export const resizeImage = async (base64, width, height) => {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const scale = height / img.height;
|
||||
const w = img.width * scale;
|
||||
const h = img.height * scale;
|
||||
const x = (width - w) / 2;
|
||||
const y = 0;
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
ctx.drawImage(img, x, y, w, h);
|
||||
resolve(canvas.toDataURL());
|
||||
};
|
||||
img.onerror = reject;
|
||||
|
||||
Reference in New Issue
Block a user