feat: crop pfp to at most 1024px (#183)

This commit is contained in:
Menci 2025-10-08 04:20:49 +08:00 committed by GitHub
parent dd03ca38a1
commit a33ec8b11c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,11 +80,12 @@
// Don't know why this isn't just a part of the cropper module. Have to do this myself.. What a shame
let canvas = document.createElement("canvas");
let ctx = canvas.getContext("2d");
canvas.width = 256;
canvas.height = 256;
const size = Math.round(Math.min(pfpCrop.width, pfpCrop.height, 1024));
canvas.width = size;
canvas.height = size;
let img = document.createElement("img");
img.onload = () => {
ctx?.drawImage(img, pfpCrop.x, pfpCrop.y, pfpCrop.width, pfpCrop.height, 0, 0, 256, 256);
ctx?.drawImage(img, pfpCrop.x, pfpCrop.y, pfpCrop.width, pfpCrop.height, 0, 0, size, size);
canvas.toBlob(blob => {
if (!blob) return;
submitting = 'profilePicture'
@ -282,7 +283,7 @@
object-fit: cover
aspect-ratio: 1
.cropper-container
position: relative