←back to thread

A new PNG spec

(www.programmax.net)
616 points bluedel | 2 comments | | HN request time: 0.708s | source
Show context
qwertox ◴[] No.44373847[source]
> Officially supports Exif data

Probably the best news here. While you already can write custom data into a header, having Exif is good.

BTW: Does Exif have a magnetometer (rotation) and acceleration (gravity) field? I often wonder about why Google isn't saving this information in the images which the camera app saves. It could help so much with post-processing, like with leveling the horizon or creating panoramas.

replies(7): >>44373955 #>>44373957 #>>44373987 #>>44375555 #>>44376496 #>>44382700 #>>44384608 #
Aardwolf ◴[] No.44373955[source]
Exif can also cause confusion for how to render the image: should its rotation be applied or not?

Old decoders and new decoders now could render an image with exif rotation differently since it's an optional chunk that can be ignored, and even for new decoders, the spec lists no decoder recommendations for how to use the exif rotation

It does say "It is recommended that unless a decoder has independent knowledge of the validity of the Exif data, the data should be considered to be of historical value only.", so hopefully the rotation will not be used by renderers, but it's only a vague recommendation, there's no strict "don't rotate the image" which would be the only backwards compatible way

With jpeg's exif, there have also been bugs with the rotation being applied twice, e.g. desktop environment and underlying library both doing it independently

replies(1): >>44374585 #
DidYaWipe ◴[] No.44374585[source]
The stupid thing is that any device with an orientation sensor is still writing images the wrong way and then setting a flag, expecting every viewing application to rotate the image.

The camera knows which way it's oriented, so it should just write the pixels out in the correct order. Write the upper-left pixel first. Then the next one. And so on. WTF.

replies(4): >>44374826 #>>44375663 #>>44376252 #>>44378679 #
klabb3 ◴[] No.44376252[source]
TIL, and hard agree (on face value). I’ve been struck by this with arbitrary rotation of images depending on application, very annoying.

What are the arguments for this? It would seem easier for everyone to rotate and then store exif for the original rotation if necessary.

replies(1): >>44376856 #
kllrnohj ◴[] No.44376856[source]
> What are the arguments for this? It would seem easier for everyone to rotate and then store exif for the original rotation if necessary.

Performance. Rotation during rendering is often free, whereas the camera would need an intermediate buffer + copy if it's unable to change the way it samples from the sensor itself.

replies(2): >>44376911 #>>44382757 #
airstrike ◴[] No.44376911[source]
How is rotation during rendering free?
replies(2): >>44377445 #>>44378101 #
kllrnohj ◴[] No.44378101[source]
For anything GPU-rendered, applying a rotation matrix to a texture sample and/or frame-buffer write is trivially cheap (see also why Vulkan prerotation exists on Android). Even ignoring GPU-rendering, you always are doing a copy as part of rendering and often have some sort of matrix operation anyway at which point concatenating a rotation matrix often doesn't change much of anything.
replies(1): >>44385579 #
1. account42 ◴[] No.44385579[source]
The cost is paid in different memory access patterns which may or may not be mitigated by the GPU scheduler. It's an insignificant cost either way though, both for the encoder and the renderer. Also depending on the pixel order in sensor, file or frame buffer "rotated" might actually be the native way and the default is where things get flipped around from source to destination.
replies(1): >>44387043 #
2. kllrnohj ◴[] No.44387043[source]
Access pattern is mitigated by texture swizzling which will happen regardless of how it's ultimately rendered. So even if drawn with an identity matrix you're still "paying" for it regardless just due to the underlying texture layout. GPUs can sample from linear textures, but often it comes with a significant performance penalty unless you stay on a specific, and undefined, path.