Skip to content

Commit

Permalink
feat: Implement file and directory handling in save function
Browse files Browse the repository at this point in the history
- Add handling for different source and target path scenarios
- Add basic structure for file and directory processing cases
- Add input validation for source path
- Prepare for comprehensive save function logic
  • Loading branch information
developer0hye committed Feb 12, 2025
1 parent d3fdd14 commit bb73211
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion imgdiet/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,23 @@ def save(
logger = setup_logger(verbose)
src_path = Path(source)
dst_path = Path(target)
dst_path.mkdir(parents=True, exist_ok=True)
valid_exts = {".jpg", ".jpeg", ".png", ".bmp", ".tif", ".tiff", ".webp", ".avif"}

if src_path.is_file():
# case 1 src_path is file and dst_path is file

# case 2 src_path is file and dst_path is dir

pass
elif src_path.is_dir():
# case 1 src_path is dir and dst_path is file

# case 2 src_path is dir and dst_path is dir

pass
else:
raise ValueError(f"Invalid source path: {source}")

# Check extension is same with codec
if dst_path.suffix and not dst_path.is_dir():
if dst_path.suffix.lower() != f".{codec}":
Expand Down

0 comments on commit bb73211

Please sign in to comment.