←back to thread

94 points justin-reeves | 10 comments | | HN request time: 0.237s | source | bottom
1. donatj ◴[] No.46004961[source]
Interesting. I was not aware that was a thing. Orientation info seems way less useful in a lossless format like PNG. It makes sense in JPEG for instance because rotating and re-encoding would be lossy and slightly degrade the image.
replies(6): >>46005026 #>>46005034 #>>46005049 #>>46005146 #>>46005413 #>>46010103 #
2. MontagFTB ◴[] No.46005026[source]
Looping through inflate/deflate on rotated pixels still takes more time than updating a bit in the Exif (and the chunk’s associated CRC)
replies(1): >>46005341 #
3. mavhc ◴[] No.46005034[source]
Depends on whether the number of pixels is a multiple of the block size

https://www.betterjpeg.com/lossless-rotation.htm

4. PaoloBarbolini ◴[] No.46005049[source]
The image could have been encoded with a high compression ratio, or even something like OxiPNG. In that case, while re-encoding it wouldn't lose quality, it could still have the side-effect of making the file bigger.
replies(1): >>46005310 #
5. poizan42 ◴[] No.46005146[source]
The orientation data is defined as part of Exif. Both JPEG and PNG has officially supported ways of embedding Exif data. It's not defined specifically for PNG, but you would expect the Exif tag to work the same way regardless of image data format.
replies(1): >>46005219 #
6. bawolff ◴[] No.46005219[source]
I dont think i would. Exif contains a bunch of metadata that affect the interpretation of image data in jpegs which dont make sense for pngs. I would expect exif in png would only be for metadata meant for humans like who the author is, not things that alter the display of the image.
7. kevincox ◴[] No.46005310[source]
At they very least it will take time. Rotating is a fairly common operation, even simple photo viewers often have buttons to quickly rotate the image. Being able to do this efficently is beneficial.

You can also have other situations where this is useful like a primarily hardware pipeline that doesn't support rotation, but you can mark the rotation at the end. Although this is probably less of an issue for PNG than formats that typically come out of cameras and scanners.

8. crazygringo ◴[] No.46005341[source]
It's still negligible from the consumer standpoint.

Like, if you had millions of images you needed to rotate on a server in a batch job, then OK.

But if you're just rotating one photo, or even a hundred, that you've just taken, it's plenty fast enough.

9. bobmcnamara ◴[] No.46005413[source]
It's hella useful when the encoder doesn't have the RAM to hold the entire image. But this is a pretty rare case.

JPEG rotation only has to be lossy when the image is not evenly divisible into macro blocks - rather than transcoding just rotate the macro blocks, and where they're placed.

10. gpvos ◴[] No.46010103[source]
JPEGs can be rotated losslessly as long as their size is a multiple of eight (or to be pedantic, the block size, which is usually eight).