Remove ffmpeg & heic-convert dependencies.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import fs from "fs-extra";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
@@ -9,7 +7,9 @@ import path, { resolve } from "path";
|
||||
import { logger } from "../server";
|
||||
import { FolderPaths } from "./serverInit";
|
||||
|
||||
const heicConverter = require("heic-convert");
|
||||
//const heicConverter = require("heic-convert");
|
||||
import gm from "gm";
|
||||
var imageMagick = gm.subClass({ imageMagick: true });
|
||||
|
||||
//gm.subClass();
|
||||
dotenv.config({
|
||||
@@ -59,10 +59,12 @@ export async function ConvertHeicFiles(files: Express.Multer.File[]) {
|
||||
async function ConvertToJpeg(file: string, newPath: string) {
|
||||
const fileOnDisk: Buffer = await fs.readFile(file);
|
||||
|
||||
const outputBuffer = await heicConverter({
|
||||
buffer: fileOnDisk, // the HEIC file buffer
|
||||
format: "JPEG", // output format
|
||||
quality: process.env.CONVERT_QUALITY || 0.5, // the jpeg compression quality, between 0 and 1
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const result = imageMagick(fileOnDisk)
|
||||
.setFormat("jpg")
|
||||
.write(newPath, (error) => {
|
||||
if (error) reject(error.message);
|
||||
resolve(newPath);
|
||||
});
|
||||
});
|
||||
return await fs.writeFile(newPath, outputBuffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user