Skip to content

convert("LAB") fails for RGB #6643

@tkzv

Description

@tkzv

What did you do?

Called PIL.Image.Image.convert(mode='LAB') for an RGB image

img = PIL.Image.open('filename.png').convert(mode='LAB')

What did you expect to happen?

Conversion of data to LAB colourspace.

What actually happened?

ValueError: conversion from RGB to LAB not supported

The following code did work:

rgb_lab_transform = PIL.ImageCms.buildTransformFromOpenProfiles(PIL.ImageCms.createProfile('sRGB'), PIL.ImageCms.createProfile('LAB'), 'RGB', 'LAB')
img = PIL.ImageCms.applyTransform(Image.open('filename.png').convert(mode='RGB'), rgb_lab_transform)

What are your OS, Python and Pillow versions?

  • OS: Linux, kernel 5.15.32-gentoo-r1
  • Python: 3.10.6
  • Pillow: 9.2.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions