Conversation
|
I don't necessarily mind this, but should we take a minute to consider why we reject zero-dimension images? The behaviour started in PIL. I imagine the initial thinking was that it was a sanity check - surely the plugin must have missed a step, because who would want a zero-dimension image? Well, it turns out that Pillow can save ICNS, ICO and SGI images as (0, 0), and someone has actually tried saving zero-dimension images. If The simple response that 'this is still a sanity check, and no one actually wants to load zero-dimension images' may be a valid answer, I just wanted to raise the question. |
From a mathematical standpoint, there's no great reason not to (in fact, zero-dimension arrays are fine in NumPy, and For instance, the whole zero-width-but-tall-image allocation surprise, #9957 (review) etc. isn't very graceful in my books, but fixing it (namely that no image data pointers are allocated whatsoever for zero-dimension images) is a larger change.
I think that's often against the specs (or reference decoders) of said image formats, so such a file in those formats shouldn't exist to begin with. A quick look at some common formats' specs:
and so on. On the other hand, e.g. HDF5 explicitly allows zero-sized datasets, but notes that no data would be written.
I think that's a good enough answer, because e.g. ImageMagick also refuses to work with the new test TIFFs' second IFDs: |
While zero-dimension images (touched upon in #9673, #9997, #9856) are creatable in Pillow, they were generally refused from input files, except when seeking into a non-first IFD of a TIFF file.
This PR:
mmapfor cases where it would be erroneous