Skip to content

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jul 3, 2025

Further discussion in #9018 has suggested that some of the functionality in the fromarray() mode argument is still useful.

#9018 (comment)

When this was proposed, there was the one legitimate use case mentioned (P), this is definitely another. Specifying that the uint8 pixels represent YCbCr instead of RGB is the sort of cast that is safe and useful for importing -- it's essentially the same operation as specifying a colorspace -- rather than specifying a bit layout which is what trips people up.

This PR restores it for changing

  • L -> P
  • LA -> La, PA
  • RGB -> YCbCr, LAB, HSV
  • RGBA -> RGBa, RGBX, CMYK

@djhoese
Copy link

djhoese commented Jul 25, 2025

Any idea when this might be merged? And any idea what version it might be released in?

The previous deprecation has been causing a lot of warnings in my projects which I think this PR should fix. Thanks for allowing these cases.

@radarhere
Copy link
Member Author

Pillow 12.0.0 is scheduled for October 15. I expect that it will be merged by then.

@radarhere radarhere added this to the 12.0.0 milestone Jul 26, 2025
Comment on lines 38 to 42
Using the ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` to change data types
has been deprecated. Since pixel values do not contain information about palettes or
color spaces, the parameter can still be used to place grayscale L mode data within a
P mode image, or read RGB data as YCbCr for example. If omitted, the mode will be
automatically determined from the object's shape and type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let's give a mention what happened in 11.3.0 and what's updated for 12.0.0.

It's good that's been added to the 11.3/12 release notes, but let's also include here for those who just read this.

@hugovk hugovk merged commit ba04d58 into python-pillow:main Sep 4, 2025
51 checks passed
@radarhere radarhere deleted the fromarray_mode branch September 4, 2025 13:57
@weathon
Copy link

weathon commented Sep 26, 2025

I am converting from HSV space. And I get the warning. Is this solved in latest version?

@djhoese
Copy link

djhoese commented Sep 26, 2025

Nope, not yet: #9063 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants