Skip to content

[BUG]: Does not work with .jpg #1

@Zyin055

Description

@Zyin055

Description of the bug

When using "File format for images" set to "jpg" in the Automatic1111 settings tab, produces the following error when using the script with default settings:

  File "C:\Stuff\AI\Stable Diffusion\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 630, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'P'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Stuff\AI\Stable Diffusion\modules\ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "C:\Stuff\AI\Stable Diffusion\webui.py", line 54, in f
    res = func(*args, **kwargs)
  File "C:\Stuff\AI\Stable Diffusion\modules\txt2img.py", line 45, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "C:\Stuff\AI\Stable Diffusion\modules\scripts.py", line 296, in run
    processed = script.run(p, *script_args)
  File "C:\Stuff\AI\Stable Diffusion\scripts\pixel_art.py", line 72, in run
    images.save_image(proc.images[i], p.outpath_samples, "",
  File "C:\Stuff\AI\Stable Diffusion\modules\images.py", line 520, in save_image
    image.save(fullfn, quality=opts.jpeg_quality)
  File "C:\Stuff\AI\Stable Diffusion\venv\lib\site-packages\PIL\Image.py", line 2320, in save
    save_handler(self, fp, filename)
  File "C:\Stuff\AI\Stable Diffusion\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 632, in _save
    raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode P as JPEG

Setting it to "png" makes it work as expected.

Steps To Reproduce

  1. "File format for images" set to "jpg"
  2. Use the script to generate any image

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions