- Notifications
You must be signed in to change notification settings - Fork 0
[pull] master from x4nth055:master#12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
pullbot commented May 30, 2025 • edited by sourcery-ai bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by sourcery-ai bot
Uh oh!
There was an error while loading. Please reload this page.
Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information |
sourcery-aibot commented May 30, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Reviewer's GuideThis PR overhauls the image compression utility by integrating structured logging and argparse, refactoring the core compression function to support advanced options, adding batch processing with a progress bar, revamping the CLI entry point for multiple inputs and new flags, and updating the README with comprehensive usage details. Sequence Diagram for Single Image Compression (compress_image function)sequenceDiagram participant CLI as Command Line participant Script as compress_image.py participant Pillow participant Logger CLI->>+Script: Execute with image_path, quality, resize_ratio, etc. Script->>Script: compress_image(input_path, output_dir, quality, ...) Script->>Logger: info("[*] Processing: ...") Script->>Pillow: Image.open(input_path) Pillow-->>Script: img object Script->>Logger: info("[*] Original size: ...") alt Resize image (if resize_ratio < 1.0 or width/height specified) Script->>Pillow: img.resize(new_size, Image.LANCZOS) Pillow-->>Script: resized img object Script->>Logger: info("[+] Resized to: ...") end Script->>Script: Determine output_path (with _compressed suffix, optional .jpg) Script->>Pillow: img.save(output_path, quality=quality, optimize=True, exif=exif_data, lossless=lossless_flag) alt OSError (e.g., saving RGBA as JPEG) Script->>Pillow: img.convert("RGB") Pillow-->>Script: RGB img object Script->>Pillow: img.save(output_path, quality=quality, optimize=True, exif=exif_data, lossless=lossless_flag) end Pillow-->>Script: Save confirmation Script->>Logger: info("[+] Saved to: ...") Script->>Logger: info("[+] New size: ...") opt Error during processing Script->>Logger: error("[!] Error processing ...") end Script-->>-CLI: Completion / Logs output to console Sequence Diagram for Batch Image Compression (batch_compress function)sequenceDiagram participant UserCLI as User via CLI participant Script as compress_image.py participant tqdm as Progress Bar participant Filesystem UserCLI->>+Script: python compress_image.py [inputs] [options] Script->>Script: batch_compress(input_paths, output_dir, quality, ...) opt output_dir specified and not exists Script->>Filesystem: os.makedirs(output_dir, exist_ok=True) end Script->>tqdm: tqdm(input_paths, desc="Compressing images") loop For each path in input_paths tqdm->>Script: next path Script->>Script: compress_image(path, output_dir, quality, ...) %% compress_image handles opening, logging, resizing, saving, and further logging end tqdm->>Script: Iteration complete Script-->>-UserCLI: All images processed / Logs output File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Introduce a fully-featured image compression CLI supporting batch processing, extensive customization, and detailed logging.
New Features:
Enhancements:
Documentation: