mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-08-10 08:00:32 +02:00
- Expand ruff rules (B, S, SIM, RET, COM, C4, G, PT, PIE, T20, DTZ, ICN, TCH, RUF, ANN) - Switch pyright to strict mode with relaxed test environment - Replace try-except-pass with contextlib.suppress throughout - Move type-only imports into TYPE_CHECKING blocks - Replace ambiguous Unicode chars (en dash, multiplication sign, Greek alpha) with ASCII - Move color-matcher from base deps to [gpu], remove unused requests dep - Add pyright to dev deps, update dependabot to uv ecosystem - Fix hardcoded version in test_version, unused unpacked vars in tests - Update maintain.sh, CLAUDE.md, .gitignore, .claude/settings.json - Remove obsolete .agents/rules/project.md - Upgrade all dependencies (Pygments vulnerability fix) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
44 lines
1007 B
Python
44 lines
1007 B
Python
"""Low-level utility helpers used across the metadata pipeline.
|
|
|
|
Kept deliberately small — only format detection lives here so that
|
|
higher-level modules can import without circular dependencies.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
from remove_ai_watermarks.noai.constants import SUPPORTED_FORMATS
|
|
|
|
|
|
def is_supported_format(file_path: Path) -> bool:
|
|
"""
|
|
Check if the file format is supported.
|
|
|
|
Args:
|
|
file_path: Path to the image file.
|
|
|
|
Returns:
|
|
True if the format is supported, False otherwise.
|
|
"""
|
|
return file_path.suffix.lower() in SUPPORTED_FORMATS
|
|
|
|
|
|
def get_image_format(file_path: Path) -> str:
|
|
"""
|
|
Get the image format from file path.
|
|
|
|
Args:
|
|
file_path: Path to the image file.
|
|
|
|
Returns:
|
|
Format string (PNG, JPEG, etc.).
|
|
"""
|
|
suffix = file_path.suffix.lower()
|
|
if suffix in {".jpg", ".jpeg"}:
|
|
return "JPEG"
|
|
return "PNG"
|