mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-03-28 19:23:15 +00:00
fix: cropping images decreases resolution
This commit is contained in:
parent
1e1c38ffc0
commit
a6b444fcea
2 changed files with 11 additions and 9 deletions
|
|
@ -32,10 +32,10 @@ export default function CropPortrait({ isOpen, setIsOpen, image, setImage }: Pro
|
||||||
const scaleX = image.naturalWidth / image.width;
|
const scaleX = image.naturalWidth / image.width;
|
||||||
const scaleY = image.naturalHeight / image.height;
|
const scaleY = image.naturalHeight / image.height;
|
||||||
|
|
||||||
canvas.width = crop.width;
|
canvas.width = crop.width * scaleX;
|
||||||
canvas.height = crop.height;
|
canvas.height = crop.height * scaleY;
|
||||||
|
|
||||||
ctx.drawImage(image, crop.x * scaleX, crop.y * scaleY, crop.width * scaleX, crop.height * scaleY, 0, 0, crop.width, crop.height);
|
ctx.drawImage(image, crop.x * scaleX, crop.y * scaleY, crop.width * scaleX, crop.height * scaleY, 0, 0, crop.width * scaleX, crop.height * scaleY);
|
||||||
|
|
||||||
setImage(canvas.toDataURL());
|
setImage(canvas.toDataURL());
|
||||||
close();
|
close();
|
||||||
|
|
|
||||||
|
|
@ -282,12 +282,14 @@ export const switchMiiInstructionsSchema = z
|
||||||
height: z.number().int().min(0).max(128).optional(),
|
height: z.number().int().min(0).max(128).optional(),
|
||||||
weight: z.number().int().min(0).max(128).optional(),
|
weight: z.number().int().min(0).max(128).optional(),
|
||||||
datingPreferences: z.array(z.enum(MiiGender)).optional(),
|
datingPreferences: z.array(z.enum(MiiGender)).optional(),
|
||||||
birthday: z.object({
|
birthday: z
|
||||||
|
.object({
|
||||||
day: z.number().int().min(1).max(31).optional(),
|
day: z.number().int().min(1).max(31).optional(),
|
||||||
month: z.number().int().min(1).max(12).optional(),
|
month: z.number().int().min(1).max(12).optional(),
|
||||||
age: z.number().int().min(1).max(100).optional(),
|
age: z.number().int().min(1).max(100).optional(),
|
||||||
dontAge: z.boolean().optional(),
|
dontAge: z.boolean().optional(),
|
||||||
}),
|
})
|
||||||
|
.optional(),
|
||||||
voice: z
|
voice: z
|
||||||
.object({
|
.object({
|
||||||
speed: z.number().int().min(0).max(50).optional(),
|
speed: z.number().int().min(0).max(50).optional(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue