1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-18 18:35:58 +01:00
upscayl/renderer/components/settings-tab/ImageFormatSelect.tsx

67 lines
1.9 KiB
TypeScript
Raw Normal View History

2023-11-23 06:39:46 +01:00
import { noImageProcessingAtom } from "@/atoms/userSettingsAtom";
import { useAtomValue } from "jotai";
import React, { useEffect } from "react";
2023-07-22 13:07:53 +02:00
type ImageFormatSelectProps = {
batchMode: boolean;
saveImageAs: string;
setExportType: (arg: string) => void;
};
export function ImageFormatSelect({
batchMode,
saveImageAs,
setExportType,
}: ImageFormatSelectProps) {
2023-11-23 06:39:46 +01:00
const noImageProcessing = useAtomValue(noImageProcessingAtom);
useEffect(() => {
if (noImageProcessing) {
setExportType("png");
}
}, [noImageProcessing]);
2023-07-22 13:07:53 +02:00
return (
<div className="flex flex-col gap-2">
<div className="flex flex-row gap-1">
<p className="text-sm font-medium">SAVE IMAGE AS</p>
2023-11-23 06:39:46 +01:00
{/* <p className="badge-primary badge text-[10px] font-medium">
2023-07-22 13:07:53 +02:00
EXPERIMENTAL
2023-11-23 06:39:46 +01:00
</p> */}
2023-07-22 13:07:53 +02:00
</div>
<div className="flex flex-col gap-2">
2023-11-23 06:39:46 +01:00
{batchMode && <p className="text-xs text-base-content/80"></p>}
{noImageProcessing && (
<p className="text-xs text-base-content/80">
{batchMode && "Only PNG is supported in Batch Upscayl."} Only PNGs
are saved without image processing to preserve image quality.
2023-07-22 13:07:53 +02:00
</p>
)}
<div className="flex flex-wrap gap-2">
{/* PNG */}
<button
2023-11-23 06:39:46 +01:00
className={`btn ${saveImageAs === "png" && "btn-primary"}`}
2023-07-22 13:07:53 +02:00
onClick={() => setExportType("png")}>
PNG
</button>
{/* JPG */}
<button
2023-11-23 06:39:46 +01:00
className={`btn ${saveImageAs === "jpg" && "btn-primary"}`}
onClick={() => setExportType("jpg")}
disabled={noImageProcessing}>
2023-07-22 13:07:53 +02:00
JPG
</button>
2023-08-30 06:54:16 +02:00
{/* WEBP
2023-07-22 13:07:53 +02:00
<button
2023-09-10 21:20:28 +02:00
className={`btn ${
saveImageAs === "webp" && "btn-primary"
2023-07-22 13:07:53 +02:00
}`}
onClick={() => setExportType("webp")}>
WEBP
2023-08-30 06:54:16 +02:00
</button> */}
2023-07-22 13:07:53 +02:00
</div>
</div>
</div>
);
}