Skip to content

Add functionality: copy skipped conversions to output dir, add 'jpeg' supported conversions, jpg quality instantiation #27

@Daethyra

Description

@Daethyra

Copy skipped conversions

if input_ext == output_ext:
            # If the input and output formats are the same, move the file instead of re-saving it
            # self._move_or_error()
            print(
                f"Skipping conversion for {self.input_path} (already in {self.output_format} format)"
            )
            return

Add 'jpeg' to supported conversions

    SUPPORTED_CONVERSIONS = {
        ".jpg": {".jpg", ".png", ".bmp", ".webp"},
        ".png": {".jpg", ".png", ".bmp", ".webp"},
        ".bmp": {".jpg", ".png", ".bmp", ".webp"},
        ".webp": {".jpg", ".png", ".bmp", ".webp"},
    }

I think then becomes:

    SUPPORTED_CONVERSIONS = {
        **{ext: {".jpg", ".png", ".bmp", ".webp"} 
            for ext in [".jpg", ".jpeg"]},
        ".png": {".jpg", ".png", ".bmp", ".webp"},
        ".bmp": {".jpg", ".png", ".bmp", ".webp"},
        ".webp": {".jpg", ".png", ".bmp", ".webp"},
    }

but I'm unsure if I'm doing that right.

JPG quality flexibility

First I'd initialize the current hardcoded jpg quality

    def __init__(self, input_path: str, output_path: str, output_format: str, jpg_quality=95):
        self.jpg_quality = jpg_quality

Then I'd have to pass that in during _convert_to_jpg

rgb_img.save(self.output_path, 'JPEG', quality=self.jpg_quality)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions