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

handle CMYK images #656

Open
bertsky opened this issue Jan 13, 2021 · 1 comment
Open

handle CMYK images #656

bertsky opened this issue Jan 13, 2021 · 1 comment
Assignees

Comments

@bertsky
Copy link
Collaborator

bertsky commented Jan 13, 2021

In addition to #627, we need to convert input images of the following color spaces to plain RGB at the beginning:

  • CMYK
  • HSV
  • YCbCr
  • LAB

I'm sure there are even more modes which Pillow does not support (see here), but let's concentrate on the modes which the PNG plugin does not support: Compare this list of Image modes with that list of PNG modes.

@bertsky
Copy link
Collaborator Author

bertsky commented Jan 13, 2021

Example stack trace:

Traceback (most recent call last):
  File "/build/core/ocrd/ocrd/processor/helpers.py", line 101, in run_api
    processor.process()
  File "/build/ocrd_segment/ocrd_segment/replace_original.py", line 78, in process
    mimetype='image/png')
  File "/build/core/ocrd/ocrd/workspace.py", line 820, in save_image_file
    image.save(image_bytes, format=MIME_TO_PIL[mimetype])
  File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2151, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python3.6/dist-
packages/PIL/PngImagePlugin.py", line 1222, in _save
    raise OSError(f"cannot write mode {mode} as PNG") from e
OSError: cannot write mode CMYK as PNG Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/PIL/PngImagePlugin.py", line 1220, in _save
    rawmode, mode = _OUTMODES[mode]
KeyError: 'CMYK'

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

2 participants