Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

feat: svgz support, fix svg detected as xml

JovannMC257bcb3b2bb6
diff --git a/src/lib/converters/magick/magick.svelte.ts b/src/lib/converters/magick/magick.svelte.ts
index d777da9..b34d789 100644
--- a/src/lib/converters/magick/magick.svelte.ts
+++ b/src/lib/converters/magick/magick.svelte.ts
@@ -42,6 +42,7 @@ export class MagickConverter extends Converter {
new FormatInfo("webp", true, true),
new FormatInfo("gif", true, true),
new FormatInfo("svg", true, true),
+ new FormatInfo("svgz", true, true),
new FormatInfo("jxl", true, true),
new FormatInfo("avif", true, true),
new FormatInfo("heic", true, false), // seems to be unreliable? HEIC/HEIF is very weird if it will actually work
@@ -330,7 +331,7 @@ export class MagickConverter extends Converter {
const startedAt = performance.now();
// handle converting from SVG manually because magick-wasm doesn't support it
- if (input.from === ".svg") {
+ if (input.from === ".svg" || input.from === ".svgz") {
try {
const blob = await this.svgToImage(input);
const pngFile = new VertFile(
diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts
index eeff6d5..dad4eec 100644
--- a/src/lib/types/file.svelte.ts
+++ b/src/lib/types/file.svelte.ts
@@ -354,6 +354,8 @@ export class VertFile {
m4b: "m4b",
aifc: "aifc",
aiff: "aiff",
+ svg: "svg",
+ svgz: "svgz",
};
const aliases: Record<string, string> = {
// original: alias
diff --git a/src/lib/workers/vips.ts b/src/lib/workers/vips.ts
index cb6dabf..3dea49e 100644
--- a/src/lib/workers/vips.ts
+++ b/src/lib/workers/vips.ts
@@ -12,9 +12,10 @@ const WASM_URLS: Record<string, string> = {
};
// note: dynamic libraries still cause wasm-vips to take a long time to (or never) initialize, imagemagick handles all these anyways
+// TODO: check if this is actually true now, issue i had while troubleshooting wasn't this
const DYNAMIC_LIBRARIES: string[] = [];
-const NO_QUALITY = new Set([".gif", ".svg", ".ppm", ".pnm"]);
+const NO_QUALITY = new Set([".gif", ".svg", ".svgz", ".ppm", ".pnm"]);
const OPAQUE = new Set([".jpg", ".jpeg", ".jpe", ".jfif", ".ppm", ".pnm"]);
const COLOURSPACES: Record<string, string> = {