Saving Image with different ColorProfile



  • Hello,
    I am stuck with a problem where I try to open an image in ImageObject() apply a .dotScreen filter 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 imageColorSyncProfileData is 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.
    Thank you.



  • hello @imik,

    I think conversions between color modes and color profiles are better handled with PIL/Pillow.

    here’s a small script to convert a .png image 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:

    1. go to the menu Python > Install Python packages…
    2. choose Install/Upgrade and type Pillow

    hops this helps… good luck!



  • Hey @gferreira,
    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 imageColorSyncProfileData and how to use it that would be great! Always happy to learn something new.

    Have a great day. 🙂


  • admin

    you need color profile data:

    like this one https://github.com/haasn/cms/blob/master/Adobe ICC Profiles (end-user)/RGB/AppleRGB.icc

    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)
    

    good luck!!


  • admin



  • Hey @frederik
    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 imageColorSyncProfileData needs.

    Anyway, thanks again for your help. 🙂


Log in to reply