Skip to content

Commit

Permalink
fix: apply to profile images as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-ext committed Feb 26, 2024
1 parent ffc6ab4 commit 5665cc1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,20 @@ export const compressProfileImage = async (
maxW: number,
maxH: number,
): Promise<CompressResult> => {
{
const exifRemoved = removeExif(await blob.arrayBuffer());

if (exifRemoved !== null) {
blob = new Blob([exifRemoved], { type: blob.type });
}
}

const image = await getImageFromBlob(blob);

if (blob.size <= MAX_SIZE) {
return { blob: blob, ratio: { width: image.naturalWidth, height: image.naturalHeight } };
}

const [canvas, width, height] = getResizedImage(image, maxW, maxH, Crop.COVER);
const large = blob.size > 1_500_000;

Expand Down

0 comments on commit 5665cc1

Please sign in to comment.