Move piexif import to server file for code splitting
This commit is contained in:
parent
1975e7f940
commit
67c392bf62
19
src/utility/exif-server.ts
Normal file
19
src/utility/exif-server.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import * as PiExif from 'piexifjs';
|
||||
|
||||
export const removeGpsFromFile = async (
|
||||
fileBytes: ArrayBuffer
|
||||
): Promise<Blob> => {
|
||||
const base64 = Buffer.from(fileBytes).toString('base64');
|
||||
const base64Url = `data:image/jpeg;base64,${base64}`;
|
||||
|
||||
const exifObject = PiExif.load(base64Url) as Record<string, any>;
|
||||
delete exifObject.GPS;
|
||||
const exifDataWithoutGps = PiExif.dump(exifObject);
|
||||
|
||||
const data = PiExif.insert(
|
||||
exifDataWithoutGps,
|
||||
base64Url,
|
||||
);
|
||||
|
||||
return fetch(data, { cache: 'no-store' }).then(res => res.blob());
|
||||
};
|
||||
@ -1,6 +1,5 @@
|
||||
import { OrientationTypes, type ExifData } from 'ts-exif-parser';
|
||||
import { formatNumberToFraction, roundToString } from './number';
|
||||
import * as PiExif from 'piexifjs';
|
||||
|
||||
const OFFSET_REGEX = /[+-]\d\d:\d\d/;
|
||||
|
||||
@ -57,21 +56,3 @@ export const formatExposureCompensation = (exposureCompensation?: number) => {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const removeGpsFromFile = async (
|
||||
fileBytes: ArrayBuffer
|
||||
): Promise<Blob> => {
|
||||
const base64 = Buffer.from(fileBytes).toString('base64');
|
||||
const base64Url = `data:image/jpeg;base64,${base64}`;
|
||||
|
||||
const exifObject = PiExif.load(base64Url) as Record<string, any>;
|
||||
delete exifObject.GPS;
|
||||
const exifDataWithoutGps = PiExif.dump(exifObject);
|
||||
|
||||
const data = PiExif.insert(
|
||||
exifDataWithoutGps,
|
||||
base64Url,
|
||||
);
|
||||
|
||||
return fetch(data, { cache: 'no-store' }).then(res => res.blob());
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user