Skip to content
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

Poor .jpg image quality in batch swap (with solution) #203

Open
Benjamin1973 opened this issue Feb 2, 2025 · 0 comments
Open

Poor .jpg image quality in batch swap (with solution) #203

Benjamin1973 opened this issue Feb 2, 2025 · 0 comments

Comments

@Benjamin1973
Copy link

After a bit of detective work, I found that swapper.py has the following:

def batch_process()

    . . . 

    if save_path:
        for img in current_images:
            img.save(path)  # Default behavior

But it seems the default quality level for .jpg files is very very low (maybe 60?). If you don't mind hard-coding quality levels, you can try something like:

    for img in current_images:
        ext = os.path.splitext(path)[1].lower()
        if ext in [".jpg", ".jpeg"]:
            img.save(path, format="JPEG", quality=95)  # Higher quality JPEG
        elif ext == ".png":
            img.save(path, format="PNG", compress_level=0)  # Lossless PNG
        else:
            img.save(path)  # Default behavior

Othewise you'll have to modify the batch menu to include a quality setting, which shouldn't be too hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant