mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: handle HEIC images in blur-faces and red-eye-removal, show warning when no faces detected
This commit is contained in:
@@ -75,7 +75,7 @@ export function BlurFacesControls({ settings: initialSettings, onChange }: BlurF
|
||||
/>
|
||||
<div className="flex justify-between text-[10px] text-muted-foreground mt-0.5">
|
||||
<span>More faces</span>
|
||||
<span>Fewer false positives</span>
|
||||
<span>Fewer faces</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,6 +89,7 @@ export function BlurFacesSettings() {
|
||||
processAllFiles,
|
||||
processing,
|
||||
error,
|
||||
warning,
|
||||
downloadUrl,
|
||||
originalSize,
|
||||
processedSize,
|
||||
@@ -110,9 +111,10 @@ export function BlurFacesSettings() {
|
||||
<div className="space-y-4">
|
||||
<BlurFacesControls onChange={setSettings} />
|
||||
|
||||
{/* Error */}
|
||||
{error && <p className="text-xs text-red-500">{error}</p>}
|
||||
|
||||
{warning && <p className="text-xs text-amber-600 dark:text-amber-400">{warning}</p>}
|
||||
|
||||
{/* Size info */}
|
||||
{originalSize != null && processedSize != null && (
|
||||
<div className="text-xs text-muted-foreground space-y-0.5">
|
||||
|
||||
@@ -11,6 +11,7 @@ interface ProcessResult {
|
||||
originalSize: number;
|
||||
processedSize: number;
|
||||
savedFileId?: string;
|
||||
warning?: string;
|
||||
}
|
||||
|
||||
export interface ToolProgress {
|
||||
@@ -39,6 +40,7 @@ export function useToolProcessor(toolId: string) {
|
||||
useFileStore();
|
||||
|
||||
const [progress, setProgress] = useState<ToolProgress>(IDLE_PROGRESS);
|
||||
const [warning, setWarning] = useState<string | null>(null);
|
||||
const elapsedRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
const xhrRef = useRef<XMLHttpRequest | null>(null);
|
||||
const eventSourceRef = useRef<EventSource | null>(null);
|
||||
@@ -69,6 +71,7 @@ export function useToolProcessor(toolId: string) {
|
||||
const capturedIndex = useFileStore.getState().selectedIndex;
|
||||
|
||||
setError(null);
|
||||
setWarning(null);
|
||||
// Mark the target entry as processing and clear any old result
|
||||
useFileStore.getState().updateEntry(capturedIndex, {
|
||||
processedUrl: null,
|
||||
@@ -216,6 +219,7 @@ export function useToolProcessor(toolId: string) {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
try {
|
||||
const result: ProcessResult = JSON.parse(xhr.responseText);
|
||||
setWarning(result.warning ?? null);
|
||||
// Write result to the entry that was being processed (captured at
|
||||
// request time), not whatever entry happens to be selected now.
|
||||
useFileStore.getState().updateEntry(capturedIndex, {
|
||||
@@ -429,6 +433,7 @@ export function useToolProcessor(toolId: string) {
|
||||
processAllFiles,
|
||||
processing,
|
||||
error,
|
||||
warning,
|
||||
downloadUrl: processedUrl,
|
||||
originalSize,
|
||||
processedSize,
|
||||
|
||||
Reference in New Issue
Block a user