fix: disable transparency option on jpeg

This commit is contained in:
Maya 2026-02-19 18:23:12 +03:00
parent 1761227d42
commit 1c65d37963
No known key found for this signature in database
3 changed files with 17 additions and 5 deletions

View File

@ -117,6 +117,7 @@
setting.key,
value,
)}
disabled={setting.disabled}
/>
{#if setting.hasCustomInput}
{@const disabled =
@ -134,7 +135,8 @@
] ??
""}
placeholder={setting.placeholder}
{disabled}
disabled={disabled ||
setting.disabled}
oninput={(e) =>
handleSettingChange(
setting.customInputKey!,
@ -156,6 +158,7 @@
setting.key,
e.currentTarget.checked,
)}
disabled={setting.disabled}
/>
{:else if setting.type === "range"}
{@const rangeValue = (settings[
@ -170,7 +173,9 @@
{@const rangeLabel =
setting.options?.[rangeValue]
?.label ?? rangeValue}
<div class="flex items-center mt-2 gap-2">
<div
class="flex items-center mt-2 gap-2"
>
<input
type="range"
min={setting.min}
@ -187,6 +192,7 @@
nextValue,
);
}}
disabled={setting.disabled}
/>
<span
class="text-sm max-w-28 w-full text-right"
@ -208,6 +214,7 @@
setting.key,
e.currentTarget.value,
)}
disabled={setting.disabled}
/>
{/if}
</div>

View File

@ -116,7 +116,9 @@ export class MagickConverter extends Converter {
}
}
public async getAvailableSettings(): Promise<SettingDefinition[]> {
public async getAvailableSettings(
input: VertFile,
): Promise<SettingDefinition[]> {
// images - quality/compression/quantize/interlace/depth-DPI, resize, crop, rotate, flip/flop, autoOrient?, color space/bit depth, transparency settings
const global = Settings.instance.settings;
@ -163,13 +165,15 @@ export class MagickConverter extends Converter {
],
};
// allow transparency or not
// TODO: disable if jpg/jpeg input/output
// TODO: check other formats for transparency support
const fromJpeg = input.from === ".jpg" || input.from === ".jpeg" || input.from === ".jfif";
const toJpeg = input.to === ".jpg" || input.to === ".jpeg" || input.to === ".jfif";
const transparency: SettingDefinition = {
key: "transparency",
label: m["convert.settings.image.transparency"](),
type: "boolean",
default: true,
disabled: fromJpeg || toJpeg,
};
const metadata: SettingDefinition = {

View File

@ -5,6 +5,7 @@ export interface SettingDefinition {
key: string;
label: string;
type: SettingType;
disabled?: boolean;
default?: any;
placeholder?: any;
min?: number;