Skip to content

Commit 257bcb3

Browse files
committed
feat: svgz support, fix svg detected as xml
oops
1 parent b3b04c2 commit 257bcb3

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/lib/converters/magick/magick.svelte.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class MagickConverter extends Converter {
4242
new FormatInfo("webp", true, true),
4343
new FormatInfo("gif", true, true),
4444
new FormatInfo("svg", true, true),
45+
new FormatInfo("svgz", true, true),
4546
new FormatInfo("jxl", true, true),
4647
new FormatInfo("avif", true, true),
4748
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 {
330331
const startedAt = performance.now();
331332

332333
// handle converting from SVG manually because magick-wasm doesn't support it
333-
if (input.from === ".svg") {
334+
if (input.from === ".svg" || input.from === ".svgz") {
334335
try {
335336
const blob = await this.svgToImage(input);
336337
const pngFile = new VertFile(

‎src/lib/types/file.svelte.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ export class VertFile {
354354
m4b: "m4b",
355355
aifc: "aifc",
356356
aiff: "aiff",
357+
svg: "svg",
358+
svgz: "svgz",
357359
};
358360
const aliases: Record<string, string> = {
359361
// original: alias

‎src/lib/workers/vips.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const WASM_URLS: Record<string, string> = {
1212
};
1313

1414
// note: dynamic libraries still cause wasm-vips to take a long time to (or never) initialize, imagemagick handles all these anyways
15+
// TODO: check if this is actually true now, issue i had while troubleshooting wasn't this
1516
const DYNAMIC_LIBRARIES: string[] = [];
1617

17-
const NO_QUALITY = new Set([".gif", ".svg", ".ppm", ".pnm"]);
18+
const NO_QUALITY = new Set([".gif", ".svg", ".svgz", ".ppm", ".pnm"]);
1819
const OPAQUE = new Set([".jpg", ".jpeg", ".jpe", ".jfif", ".ppm", ".pnm"]);
1920

2021
const COLOURSPACES: Record<string, string> = {

0 commit comments

Comments
 (0)