fix: add libheif

issue #202
This commit is contained in:
C4illin
2025-02-12 21:06:27 +01:00
parent eacded6848
commit decfea5dc9
4 changed files with 62 additions and 1 deletions

View File

@@ -49,13 +49,16 @@ RUN apk --no-cache add \
vips-tools \
vips-poppler \
vips-jxl \
vips-heif \
vips-magick \
libjxl-tools \
assimp \
inkscape \
poppler-utils \
gcompat \
libva-utils \
py3-numpy
py3-numpy \
libheif-tools
RUN apk --no-cache add qt6-qtbase-private-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community/

View File

@@ -26,6 +26,7 @@ A self-hosted online file converter. Supports over a thousand different formats.
|------------------------------------------------------------------------------|---------------|---------------|-------------|
| [libjxl](https://github.com/libjxl/libjxl) | JPEG XL | 11 | 11 |
| [resvg](https://github.com/RazrFalcon/resvg) | SVG | 1 | 1 |
| [libheif](https://github.com/strukturag/libheif) | HEIF | 7 | 6 |
| [Vips](https://github.com/libvips/libvips) | Images | 45 | 23 |
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
| [Calibre](https://calibre-ebook.com/) | E-books | 26 | 19 |

52
src/converters/libheif.ts Normal file
View File

@@ -0,0 +1,52 @@
import { execFile } from "child_process";
export const properties = {
from: {
images: [
"avci",
"avcs",
"avif",
"h264",
"heic",
"heics",
"heif",
"heifs",
"mkv",
"mp4",
],
},
to: {
images: ["jpeg", "png", "y4m"],
},
};
export function convert(
filePath: string,
fileType: string,
convertTo: string,
targetPath: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
options?: unknown,
): Promise<string> {
return new Promise((resolve, reject) => {
execFile(
"heif-convert",
[filePath, targetPath],
(error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}
if (stdout) {
console.log(`stdout: ${stdout}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}
resolve("Done");
},
);
});
}

View File

@@ -9,6 +9,7 @@ import { convert as convertresvg, properties as propertiesresvg } from "./resvg"
import { convert as convertImage, properties as propertiesImage } from "./vips";
import { convert as convertxelatex, properties as propertiesxelatex } from "./xelatex";
import { convert as convertCalibre, properties as propertiesCalibre } from "./calibre";
import { convert as convertLibheif, properties as propertiesLibheif } from "./libheif";
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
@@ -49,6 +50,10 @@ const properties: Record<
properties: propertiesresvg,
converter: convertresvg,
},
libheif: {
properties: propertiesLibheif,
converter: convertLibheif,
},
vips: {
properties: propertiesImage,
converter: convertImage,