scripts
scripts copied to clipboard
`srgbify` can't convert this image, for some reason
When I try to convert the image in the attached ZIP, I get an error "cannot build transform". It would be good to understand what's going on and fix it.
Here's the traceback:
Traceback (most recent call last):
File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.QxFezTSFZ4/.venv/lib/python3.12/site-packages/PIL/ImageCms.py", line 463, in profileToProfile
transform = ImageCmsTransform(
^^^^^^^^^^^^^^^^^^
File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.QxFezTSFZ4/.venv/lib/python3.12/site-packages/PIL/ImageCms.py", line 306, in __init__
self.transform = core.buildTransform(
^^^^^^^^^^^^^^^^^^^^
ValueError: cannot build transform
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/alexwlchan/repos/scripts/images/srgbify.py", line 88, in <module>
out_im = convert_image_to_srgb(im)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alexwlchan/repos/scripts/images/srgbify.py", line 58, in convert_image_to_srgb
return ImageCms.profileToProfile(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.QxFezTSFZ4/.venv/lib/python3.12/site-packages/PIL/ImageCms.py", line 478, in profileToProfile
raise PyCMSError(v) from v
PIL.ImageCms.PyCMSError: cannot build transform
That core.buildTransform() function called from ImageCms.py seems to be defined somewhere in a C library, so I can't debug it further.
I'm not going to investigate this further unless I see more images with this issue – Acorn was able to handle it fine for me.