Inline constant
This commit is contained in:
parent
2c098904fb
commit
866b52b002
5 changed files with 19 additions and 20 deletions
15
web/apps/photos/src/services/heic-convert/heic-convert.ts
Normal file
15
web/apps/photos/src/services/heic-convert/heic-convert.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import HeicConvert from "heic-convert";
|
||||
import { getUint8ArrayView } from "services/readerService";
|
||||
|
||||
/**
|
||||
* Convert a HEIC file to a JPEG file.
|
||||
*
|
||||
* Both the input and output are blobs.
|
||||
*/
|
||||
export const convertHEICToJPEG = async (heicBlob: Blob): Promise<Blob> => {
|
||||
const filedata = await getUint8ArrayView(heicBlob);
|
||||
const result = await HeicConvert({ buffer: filedata, format: "JPEG" });
|
||||
const convertedFileData = new Uint8Array(result);
|
||||
const convertedFileBlob = new Blob([convertedFileData]);
|
||||
return convertedFileBlob;
|
||||
};
|
|
@ -12,7 +12,6 @@ const WORKER_POOL_SIZE = 2;
|
|||
const WAIT_TIME_BEFORE_NEXT_ATTEMPT_IN_MICROSECONDS = [100, 100];
|
||||
const WAIT_TIME_IN_MICROSECONDS = 30 * 1000;
|
||||
const BREATH_TIME_IN_MICROSECONDS = 1000;
|
||||
const CONVERT_FORMAT = "JPEG";
|
||||
|
||||
class HEICConverter {
|
||||
private convertProcessor = new QueueProcessor<Blob>();
|
||||
|
@ -44,9 +43,8 @@ class HEICConverter {
|
|||
}, WAIT_TIME_IN_MICROSECONDS);
|
||||
const startTime = Date.now();
|
||||
const convertedHEIC =
|
||||
await worker.convertHEIC(
|
||||
await worker.convertHEICToJPEG(
|
||||
fileBlob,
|
||||
CONVERT_FORMAT,
|
||||
);
|
||||
addLogLine(
|
||||
`originalFileSize:${convertBytesToHumanReadable(
|
|
@ -1,5 +1,5 @@
|
|||
import { logError } from "@ente/shared/sentry";
|
||||
import WasmHEICConverterService from "./wasmHeicConverter/wasmHEICConverterService";
|
||||
import WasmHEICConverterService from "./heic-convert/service";
|
||||
|
||||
class HeicConversionService {
|
||||
async convert(heicFileData: Blob): Promise<Blob> {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import * as HeicConvert from "heic-convert";
|
||||
import { getUint8ArrayView } from "services/readerService";
|
||||
|
||||
export async function convertHEIC(
|
||||
fileBlob: Blob,
|
||||
format: string,
|
||||
): Promise<Blob> {
|
||||
const filedata = await getUint8ArrayView(fileBlob);
|
||||
const result = await HeicConvert({ buffer: filedata, format });
|
||||
const convertedFileData = new Uint8Array(result);
|
||||
const convertedFileBlob = new Blob([convertedFileData]);
|
||||
return convertedFileBlob;
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
import * as Comlink from "comlink";
|
||||
import { convertHEIC } from "services/wasmHeicConverter/wasmHEICConverterClient";
|
||||
|
||||
export class DedicatedConvertWorker {
|
||||
async convertHEIC(fileBlob: Blob, format: string) {
|
||||
return convertHEIC(fileBlob, format);
|
||||
async convertHEICToJPEG(fileBlob: Blob) {
|
||||
return this.convertHEICToJPEG(fileBlob);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue