feat: Compress avatar images before upload (#1751)
* compress avatar images before upload * move compressImage to dedicated file * Update ImageUpload.js
This commit is contained in:
@ -10,6 +10,7 @@ import Button from "components/Button";
|
||||
import Flex from "components/Flex";
|
||||
import LoadingIndicator from "components/LoadingIndicator";
|
||||
import Modal from "components/Modal";
|
||||
import { compressImage } from "utils/compressImage";
|
||||
import { uploadFile, dataUrlToBlob } from "utils/uploadFile";
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
@ -53,7 +54,11 @@ class ImageUpload extends React.Component<Props> {
|
||||
const canvas = this.avatarEditorRef.getImage();
|
||||
const imageBlob = dataUrlToBlob(canvas.toDataURL());
|
||||
try {
|
||||
const attachment = await uploadFile(imageBlob, {
|
||||
const compressed = await compressImage(imageBlob, {
|
||||
maxHeight: 512,
|
||||
maxWidth: 512,
|
||||
});
|
||||
const attachment = await uploadFile(compressed, {
|
||||
name: this.file.name,
|
||||
public: true,
|
||||
});
|
||||
|
Reference in New Issue
Block a user