Repository navigation
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: |
|
When opening a new image, the default size is Line 637 in cce2900 So it makes more sense that something should be done by the plugin in that scenario. When seeking to another frame, if the plugin didn't do anything, the size would stay the same as the first frame, not be set to So the 'sanity check' argument doesn't quite play out in the same way, and I'd rather not introduce a constraint just because we can. |
|
@radarhere The plugin refuses a TIFF whose first IFD is 0x0 though. |
|
We reject the first frame if it is |
|
the mmap fixes here should probably be merged anyhow. I can't open a new PR for that. |
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