-
Notifications
You must be signed in to change notification settings - Fork 49
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
how to detect colorspace of an image #140
Comments
Hello, I'm not sure I understand. Could you post a sample image and explain exactly what you need to know? |
Ah OK. Just test to see if there's an ICC profile attached. x = pyvips.Image.new_from_file(...)
if x.get_typeof("icc-profile-data") != 0:
x = x.icc_transform("srgb") Now the image is in srgb colourspace. You can also do: x = pyvips.Image.new_from_file(...)
x = x.icc_transform("srgb", embedded=True, input_profile="srgb") This means: transform to srgb, use the embedded profile if possible as the input space, otherwise default to srgb for the input. |
|
You can't, unfortunately. There's no such thing as an sRGB profile, there are only profiles which (more or less accurately) implement the sRGB standard. You'll find there are dozens of sRGB profiles and they are all slightly different :( The only thing you can know for sure is that an untagged image is probably sRGB. Unless it's CMYK. |
ok! fair enough :) |
I come across almost the same issue, image.get('icc-profile-data') and get
b'\x00\x00\x02$appl\x04\x00\x00\x00mntrRGB XYZ \x07\xe1\x00\x07\x00\x07\x00\r\x00\x16\x00 acspAPPL\x00\x00\x00\x00APPL\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\xd6\x00\x01\x00\x00\x00\x00\xd3-appl\xca\x1a\x95\x82%\x7f\x10M8\x99\x13\xd5\xd1\xea\x15\x82\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ndesc\x00\x00\x00\xfc\x00\x00\x00ecprt\x00\x00\x01d\x00\x00\x00#wtpt\x00\x00\x01\x88\x00\x00\x00\x14rXYZ\x00\x00\x01\x9c\x00\x00\x00\x14gXYZ\x00\x00\x01\xb0\x00\x00\x00\x14bXYZ\x00\x00\x01\xc4\x00\x00\x00\x14rTRC\x00\x00\x01\xd8\x00\x00\x00 chad\x00\x00\x01\xf8\x00\x00\x00,bTRC\x00\x00\x01\xd8\x00\x00\x00 gTRC\x00\x00\x01\xd8\x00\x00\x00 desc\x00\x00\x00\x00\x00\x00\x00\x0b🔴Display P3🔴\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00text\x00\x00\x00\x00Copyright Apple Inc., 2017\x00\x00XYZ \x00\x00\x00\x00\x00\x00\xf3Q\x00\x01\x00\x00\x00\x01\x16\xccXYZ \x00\x00\x00\x00\x00\x00\x83\xdf\x00\x00=\xbf\xff\xff\xff\xbbXYZ \x00\x00\x00\x00\x00\x00J\xbf\x00\x00\xb17\x00\x00\n\xb9XYZ \x00\x00\x00\x00\x00\x00(8\x00\x00\x11\x0b\x00\x00\xc8\xb9para\x00\x00\x00\x00\x00\x03\x00\x00\x00\x02ff\x00\x00\xf2\xa7\x00\x00\rY\x00\x00\x13\xd0\x00\x00\n[sf32\x00\x00\x00\x00\x00\x01\x0cB\x00\x00\x05\xde\xff\xff\xf3&\x00\x00\x07\x93\x00\x00\xfd\x90\xff\xff\xfb\xa2\xff\xff\xfd\xa3\x00\x00\x03\xdc\x00\x00\xc0n' I see the embeded icc profile name "Display P3" in the output, can I get that value with pyvips for later use. To do the same thing with exiftool
and get
|
You need a module that can parse ICC profiles and extract the profile name. Just pass it the result of |
Thanks @jcupitt Just find a module that can extract the profile name ImageCms Module — Pillow (PIL Fork) 8.3.1 documentation |
I'm using
pyvips.Image.icc_transform
to convert an image's color space to sRGB.This API with a tiny, little flaw is also covert a sRGB image to sRGB.
I need to detect source image's color space, only a non-sRGB image will be converted.
The text was updated successfully, but these errors were encountered: