Closed svgeesus closed 2 years ago
@tabatkins wrote, in 2020
Chrome, Safari, and Firefox all now respect image-orientation: from-image on JPGs (in their latest versions, make sure you're updated), as shown in https://ericportis.com/etc/PNG-EXIF-orientation/.
Chrome and Firefox don't currently support it on PNGs at all (but plan to fix that). Safari does support EXIF on PNGs, but only if it comes before the image data (the PNG spec technically allows it to show up before or after). (The test linked above has the EXIF after the image data.)
At minimum we should say that Web browsers displaying images in HTML will ignore the EXIF data in PNG if it comes after IDAT
.
Preferably, we should say that eXIf
must come before IDAT
I'm currently adding the missing eXIF
chunk to the chunk-ordering diagrams, so blocked on what we decide here. https://github.com/w3c/PNG-spec/pull/142
Also this useful comment by @eeeps
It might be helpful to differentiate between render-impacting and non-render-impacting metadata, and not be specific about the EXIF metadata format.
Encoders often want to put non-render-impacting metadata after the image data, so that image data is received (and in the case of progressive formats, can be painted) ASAP. See for instance, the suggested order of "extended" WebP metadata: https://developers.google.com/speed/webp/docs/riff_container#extended_file_format
Some formats may go further and mandate, rather than suggest, that EXIF come after. I think JPEG-XL does this? (though, IIRC, it has special-purpose format-specific metadata fields for render-impacting things like orientation and resolution that must come before image data). cc: @jonsneyers
Actually, looking at the Chunk ordering requirements almost all chunks are required before IDAT
. The only ones that are not are:
IEND
(obviously)fdAT
(animation frames)fcTL
so it would be entirely consistent to require eXIf
before IDAT
.
I agree to require it before IDAT. Anything which could impact how the image is decoded / rendered should have that requirement.
EXIF is a bit odd because some data might impact decode & rendering while other data doesn't. As mentioned by @eeeps ideally we could put non-impact data at the end of the image to not delay decode / rendering. But it is what it is.
I worried that updates an old requirement to become more strict would break things. But if no browsers respected it anyway, I'm not as worried about breaking things. :)
If it was made a requirement wouldn't that technically break existing images? Usually when a known, non-critical chunk is found in the wrong location it's ignored by decoders. If this requirement was ignored (to keep compatibility with existing images) would that make the decoder non-conformant?
With web browser decoders already ignoring it, nothing in their decode->render pipeline changes. Other decoders might behave differently but at that point it is lesser-of-two-evils.
If it was made a requirement wouldn't that technically break existing images?
It could; that is because eXIf
started out in an extensions spec and was rather under-specified.
But in practice, that turns "this image is technically allowed but browsers don't display it properly" into "this image does not display properly because it is wrong (and fixable)"
Having recently edited all the lattice diagrams which show chunk ordering constraints, it is clear that the only chunks allowed after IDAT
are:
tEXt
, zTXt
, iTXt
, tIME
)IDAT
(fdAT
, fcTL
)Since eXIf
can affect display of the static image, it should be specified to come before IDAT
, which is currently the case.
I think this issue can thus be closed, with no further edits needed.
Raised by Phil Harvey phil@owl.phy.queensu.ca
Originally noted here and should have been raised as a separate issue