Strip Exif data without Sharp

This commit is contained in:
Evan Hahn 2021-09-02 10:59:42 -05:00 committed by GitHub
parent 30c3b7630c
commit f82012f129
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 45 deletions

View file

@ -101,17 +101,6 @@ async function getCanvasBlobAsJPEG(
return canvasToBlob(canvas, IMAGE_JPEG, quality);
}
async function stripImageFileEXIFData(
file: File | Blob,
type: MIMEType
): Promise<Blob> {
const arrayBuffer = await file.arrayBuffer();
const xArrayBuffer = await window
.sharp(new Uint8Array(arrayBuffer))
.toBuffer();
return new Blob([xArrayBuffer], { type });
}
export async function scaleImageToLevel(
fileOrBlobOrURL: File | Blob,
contentType: MIMEType,
@ -143,7 +132,7 @@ export async function scaleImageToLevel(
MEDIA_QUALITY_LEVEL_DATA.get(level) || DEFAULT_LEVEL_DATA;
if (fileOrBlobOrURL.size <= thresholdSize) {
const blob = await stripImageFileEXIFData(fileOrBlobOrURL, contentType);
const blob = await canvasToBlob(image, contentType);
return {
blob,
contentType,