Remove mention that 1-bit images use 1 byte per pixel by hchargois · Pull Request #8777 · python-pillow/Pillow

This method returns the raw image data from the internal storage.

The origin of this sentence was in #1470, where one user wanted to clarify that tobytes() didn’t return data in a regular image format. It’s unfortunate that one clarification has lead to different confusion.

i think ‘raw image data' is intended to mean one-dimensional pixel data without context, and ‘from the internal storage’ is intended to mean ‘this isn’t the form the data had in any given file’

I think it's better to not give any expectations than provide false expectations.

As a general principle, I'm in favour of clarifying information. I'm not in favour of removing information because it might be misunderstood.

I think 'stored with one pixel per byte' is meant to communicate that Pillow will use more memory than you might expect.

This is kind of a specific situation to document - not so much because of the 1 mode, but because what you’re talking about just the “raw” encoder, and tobytes() can be used with other encoders. If you used any other encoder, I think it would be clearer what you received wasn't exactly what was stored internally in Pillow.

And interestingly, when this specific situation does become relevant to Pillow's internal code, there is a comment that tries to explain your scenario.

if self.mode == "1":
# Binary images need to be extended from bits to bytes
# See: https://github.com/python-pillow/Pillow/issues/350
new["data"] = self.tobytes("raw", "L")
else:
new["data"] = self.tobytes()

I've created #8878 as an alternative - it leaves in the information about how mode 1 image data is stored, mentions that tobytes() returns data derived from internal storage, and adds a reference to Pack.c.