-
Notifications
You must be signed in to change notification settings - Fork 4
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
invert_colors
fails for some image formats
#421
Comments
This issue currently has a draft PR (#422) linked, but no assignee. This is intentional. Feel free to take over the PR and finish it. |
The bug has been fixed in #419. Images are now converted to RGB format before inverting them. This might mean that inverting an image twice loses some quality compared to the original image. But we do not seem to test for this, and it's in general a pretty common thing for image operations (example: resize to a smaller size, then back to original). After having a closer look into the documentation, I also don't see any internal exceptions that could be raised when calling the |
Describe the bug
The
invert_colors
method for images internally usesImageOps.invert(...)
:src/safeds/data/image/containers/_image.py:
This
ImageOps.invert(...)
method can fail with an obscureOSError
for certain, non-RGB image formats.For example, it fails for this image that is currently used in the image documentation.
To Reproduce
Checkout the
373-tutorial-for-image-processing
branch, first commit (a3c1b1d) and run the 10th cell. (Or run everything, either in the notebook or by serving the documentation withpoetry run mkdocs serve
).Expected behavior
If possible, the
invert_colors
method should never fail.Stackoverflow has some tips on how to achieve that with
ImageOps
and non-RGB formats.For cases where it is not possible to find a workaround, the internal error from
ImageOps
should be catched and a more user-friendly error should be thrown.The text was updated successfully, but these errors were encountered: