Ask Your Question

Revision history [back]

You should know the difference between sRGB and Adobe RGB.Sorry, opencv and pillow can not complete this task very well.You should try to process the image with imagemagick first.Like this:

from PIL import Image, ImageCMS
import numpy as np
srgb = ImageCms.createProfile('sRGB')
def get_adobe(img):
    output = BytesIO()   
    output.write(img.info.get('icc_profile'))
    output.seek(0)
    adobe = ImageCms.getOpenProfile(output)     
    return adobe


def convert_to_srgb(image):
    if image.info.get('icc_profile', ''):
        adobe = get_adobe(image)
        image = ImageCms.profileToProfile(image, adobe, srgb)
    return image