mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 20:12:39 +00:00
feat: crop pfp to at most 1024px (#183)
This commit is contained in:
parent
dd03ca38a1
commit
a33ec8b11c
@ -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
|
// 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 canvas = document.createElement("canvas");
|
||||||
let ctx = canvas.getContext("2d");
|
let ctx = canvas.getContext("2d");
|
||||||
canvas.width = 256;
|
const size = Math.round(Math.min(pfpCrop.width, pfpCrop.height, 1024));
|
||||||
canvas.height = 256;
|
canvas.width = size;
|
||||||
|
canvas.height = size;
|
||||||
let img = document.createElement("img");
|
let img = document.createElement("img");
|
||||||
img.onload = () => {
|
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 => {
|
canvas.toBlob(blob => {
|
||||||
if (!blob) return;
|
if (!blob) return;
|
||||||
submitting = 'profilePicture'
|
submitting = 'profilePicture'
|
||||||
@ -282,7 +283,7 @@
|
|||||||
object-fit: cover
|
object-fit: cover
|
||||||
aspect-ratio: 1
|
aspect-ratio: 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.cropper-container
|
.cropper-container
|
||||||
position: relative
|
position: relative
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user