Author Topic: Does the forum support EXIF orientation tag in JPEG images?  (Read 1627 times)

0 Members and 1 Guest are viewing this topic.

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Does the forum support EXIF orientation tag in JPEG images?
« on: August 31, 2022, 03:05:51 pm »
Only one way to know...
 :popcorn:
 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Does the forum support EXIF orientation tag in JPEG images?
« Reply #1 on: August 31, 2022, 03:10:44 pm »
The preview generator clearly doesn't.

Moreover, the tag is stripped from the uploaded image as well, so downloaded copies appear wrong in all browsers and other software.
« Last Edit: August 31, 2022, 03:13:02 pm by magic »
 
The following users thanked this post: edavid

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Does the forum support EXIF orientation tag in JPEG images?
« Reply #2 on: August 31, 2022, 07:45:44 pm »
Ehm, yes, for those wondering what this is about.

JPEG files may contain EXIF metadata. One item of particular interest is the Exif.Image.Orientation tag, which - if present - specifies that the image should be rotated (in 90° increments) or mirrored before being shown to the user. A common source of such images are digital cameras in portrait orientation - they actually write the file in landscape orientation and then add this EXIF tag. Another source is some simple image editors and viewers, which implement "rotate left"/"rotate right" functions on JPEGs by means of altering the EXIF tag only.

Needless to say, not all software honors this EXIF tag and some websites remove some or all EXIF tags from images uploaded by users, with or without correcting the orientation. The ZIP archive attached to this post contains a JPEG file which tests any software for handling of EXIF orientation. The image is encoded upside down, and then an EXIF tag is added requesting 180° rotation.

Fixing orientation the easy way.
Open and then save the image again with a graphics editor which encodes JPEGs in correct orientation right away, without EXIF trickery. The free image editor GIMP is one such program and I suspect even MS Paint could work, if it still exists in Windows. When loading a JPEG file, GIMP will ask whether to rotate the image in accordance with EXIF metadata, you probably want to answer "yes" to that if you are here. To write a JPEG file in GIMP, you need the "export" function rather than "save" ::)

This is an opportunity to also reduce the size of your file by scaling down to fewer pixels and/or reducing the "JPEG quality factor", if no visible deterioration occurs.

Rotating JPEG images the lossless way.
The decode-encode loop described above induces quality loss, which may be undesirable if the original image already suffers from high compression. Saving at a higher quality factor could reduce the additional loss, but increases file size quite needlessly.

A few simple transformations including rotation can be performed on JPEGs losslessly, with specialized software which manipulates the compressed data directly. The image remains the same in size and decodes to the exact same pixels, but in different orientation. Limited scaling and cropping is possible too.

Free tools for this are jpegtrans and jpegcrop, developed by https://jpegclub.org/ .

BONUS: Lossless extraction of JPEGs (and other images) from PDF documents.
This can be handy too, because the file is not scaled or re-encoded in the process. Some PDF editors like LibreOffice can save images embedded in PDF documents to individual files. Some PDF images are encoded in JPEG format and should be saved us such, others are lossless and may be saved as PNG.

An alternative option on Linux is the pdfimages command line tool.
 
The following users thanked this post: thm_w, edavid

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7236
  • Country: ca
  • Non-expert
Re: Does the forum support EXIF orientation tag in JPEG images?
« Reply #3 on: August 31, 2022, 08:41:18 pm »
I guess this explains why saving some images the correct rotation is lost as its a tag.

It looks like in windows the built in rotate image is lossless: https://photo.stackexchange.com/questions/12361/are-windows-photo-viewer-rotations-lossless
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: magic

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2161
  • Country: us
Re: Does the forum support EXIF orientation tag in JPEG images?
« Reply #4 on: August 31, 2022, 09:08:04 pm »
I have the same problem with portrait mode pictures taken with my Canon T2i DSLR. They are saved  by the camera in landscape mode on the SD card, and I have found that various apps may or may not correct the orientation.  So I point JPEG Lossless Rotator (for Windows) to the folder, and it automatically re-writes those pictures into actual portrait mode format, without bothering those actually taken in landscape mode in the first place.  And it doesn't change anything else, like the date/time values.  I'm told there is a menu entry in the camera that fixes this problem, but I think that applies only if you use Canon's software to bring in the pictures.  Not sure about that.
 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Does the forum support EXIF orientation tag in JPEG images?
« Reply #5 on: August 31, 2022, 09:23:09 pm »
It looks like in windows the built in rotate image is lossless: https://photo.stackexchange.com/questions/12361/are-windows-photo-viewer-rotations-lossless
Interesting, I would have expected such a program to be EXIF-based but it seems to actually edit the data, so it's another viable option to prepare forum images.

And yes, the losless trick only works on images of dimensions that are multiples of 8 or 16 pixels, I forgot about it. But JPEGclub tools should be able to crop out the incomplete blocks at the right and bottom edge (if you are OK with losing them) and then the image can be rotated losslessly.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf