Open hrorich opened 2 years ago
i have the same issue. i select a file with size 900kB, but when i get the blob format of canvas it became 10MB. the issue is that the canvas with and height is too large like 5000. i don't know how to fix it.
This is because its always by default return PNG image, which is naturally bigger in size, then jpeg. To get jpeg use like
const canvas = editorRef.current.getImageScaledToCanvas();
const dataUrl = canvas.toDataURL('image/jpeg', 0.9);
const blob = await fetch(dataUrl).then((res) => res.blob());
const formData = new FormData();
formData.append('avatar', blob, 'avatar.jpg');
Using the utility, when we upload a .jpg image, the utility is saving it at 3-5x the original size. We uploaded a .jpg of file size 51kb, and the utility saved it as a 132kb jpeg. We uploaded a .jpg of 1MB, and the utility saved it as a 6.3MB jpeg.