Saving Image with different ColorProfile
I am stuck with a problem where I try to open an image in
.dotScreenfilter on it and save it again.
Now I always end up with an image saved with RGB profile but I would like to generate an image just black and white — no color information.
I looked into the documentation and first I thought it has something to do with
colorSpace()but I guess that is not the case.
So I ended up by the saving options and I think that
imageColorSyncProfileDatais actually what I am looking for. But I do not understand how to work with it.
For further interest I would be keen to know if there is a way to convert images into different profiles. Especially thinking about print production where I maybe need certain ICC-Profiles.
I am happy for any help or information for a solution.
gferreira last edited by
I think conversions between color modes and color profiles are better handled with PIL/Pillow.
here’s a small script to convert a
.pngimage to grayscale (thanks @frederik for the example):
from PIL import Image img = Image.open('image.png').convert('LA') img.save('greyscale.png')
you can install and use Pillow from inside DrawBot using the new pip installer:
- go to the menu Python > Install Python packages…
- choose Install/Upgrade and type Pillow
hops this helps… good luck!
thank you for you reply! I will have a more detailed look into the PIL-Library but I think that's it for the moment.
Still, if you have some further information or any idea where to find something about the
imageColorSyncProfileDataand how to use it that would be great! Always happy to learn something new.
Have a great day.
you need color profile data:
import AppKit fill(1, 0, 0) rect(20, 20, width()-40, height()-40) data = AppKit.NSData.dataWithContentsOfFile_('path/to/AppleRGB.icc') saveImage("test.tiff", imageColorSyncProfileData=data)
see futher discussion https://github.com/typemytype/drawbot/issues/344
Thank you very much for your reply.
I did some quick tests with the code you provided but it seems I have not achieved any positive result in saving the pages with the provided color profile data.
The results were always GenericRGB for TIFF, JPG and PNG regardless of me also using some other ICC files.
dataWithContentsOfFile_returns an objective-c class NSConcreteData with the data represented as b'…' in it, what I guess is right and what
Anyway, thanks again for your help.