feat: support svg and heif

prevents conversion into svg/heif (not supported by vips)
also remove outdated "animated images not supported' text
This commit is contained in:
JovannMC 2025-02-17 22:41:07 +03:00
parent 14517acdfd
commit 75e63ff94b
No known key found for this signature in database
5 changed files with 23 additions and 7 deletions

View File

@ -11,14 +11,16 @@
<div class="flex items-center flex-col md:flex-row gap-2.5 max-md:w-full"> <div class="flex items-center flex-col md:flex-row gap-2.5 max-md:w-full">
<button <button
onclick={() => files.convertAll()} onclick={() => files.convertAll()}
class="btn {$effects ? "" : "!scale-100"} highlight flex gap-3 max-md:w-full" class="btn {$effects
? ''
: '!scale-100'} highlight flex gap-3 max-md:w-full"
disabled={!files.ready} disabled={!files.ready}
> >
<RefreshCw size="24" /> <RefreshCw size="24" />
<p>Convert all</p> <p>Convert all</p>
</button> </button>
<button <button
class="btn {$effects ? "" : "!scale-100"} flex gap-3 max-md:w-full" class="btn {$effects ? '' : '!scale-100'} flex gap-3 max-md:w-full"
disabled={!files.ready || !files.results} disabled={!files.ready || !files.results}
onclick={() => files.downloadAll()} onclick={() => files.downloadAll()}
> >
@ -30,13 +32,18 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<p class="whitespace-nowrap text-xl">Set all to</p> <p class="whitespace-nowrap text-xl">Set all to</p>
{#if files.requiredConverters.length === 1} {#if files.requiredConverters.length === 1}
<!-- cannot convert to svg or heif -->
{@const supported =
files.files[0]?.converter?.supportedFormats?.filter(
(format) => format !== ".svg" && format !== ".heif",
)}
<Dropdown <Dropdown
onselect={(r) => onselect={(r) =>
files.files.forEach((f) => { files.files.forEach((f) => {
f.to = r; f.to = r;
f.result = null; f.result = null;
})} })}
options={files.files[0]?.converter?.supportedFormats || []} options={supported || []}
/> />
{:else} {:else}
<Dropdown options={["N/A"]} disabled /> <Dropdown options={["N/A"]} disabled />

View File

@ -33,9 +33,10 @@ export class VipsConverter extends Converter {
".tif", ".tif",
".tiff", ".tiff",
".jfif", ".jfif",
//".heif", HEIF files that are encoded like HEIC files (and HEIC files in general) aren't supported due to https://github.com/kleisauke/wasm-vips/issues/3 ".heif", // HEIF files that are encoded like HEIC files (and HEIC files in general) aren't supported due to https://github.com/kleisauke/wasm-vips/issues/3
".avif", ".avif",
".jxl", ".jxl",
".svg",
]; ];
public readonly reportsProgress = false; public readonly reportsProgress = false;

View File

@ -1,6 +1,8 @@
import Vips from "wasm-vips"; import Vips from "wasm-vips";
const vipsPromise = Vips(); const vipsPromise = Vips({
dynamicLibraries: ["vips-jxl.wasm", "vips-heif.wasm", "vips-resvg.wasm"],
});
vipsPromise vipsPromise
.then(() => { .then(() => {

View File

@ -63,7 +63,9 @@
</div> </div>
<div class="flex flex-col text-center justify-center"> <div class="flex flex-col text-center justify-center">
<p>Animated images are not supported (yet).</p> <p class="flex items-center justify-center gap-2">
<Check size="20" /> Fully supported
</p>
<p> <p>
<b>Supported formats:</b> <b>Supported formats:</b>
{supportedFormats.images} {supportedFormats.images}

View File

@ -182,8 +182,12 @@
<div <div
class="w-[122px] h-fit flex flex-col gap-2 items-center justify-center" class="w-[122px] h-fit flex flex-col gap-2 items-center justify-center"
> >
<!-- cannot convert to svg or heif -->
<Dropdown <Dropdown
options={file.converter?.supportedFormats || []} options={file.converter?.supportedFormats?.filter(
(format) =>
format !== ".svg" && format !== ".heif",
) || []}
bind:selected={file.to} bind:selected={file.to}
onselect={(option) => handleSelect(option, file)} onselect={(option) => handleSelect(option, file)}
/> />