immich icon indicating copy to clipboard operation
immich copied to clipboard

[BUG] Immich not using rotation value in metadata

Open ericswpark opened this issue 2 years ago • 1 comments

The bug

While images show in the proper orientation in the Preview app and Photos app on macOS, the same image imported into Immich shows the photo rotated 90 degrees counterclockwise.

In the Preview app, the "TIFF" metadata panel says "Orientation – 6 (Rotated 90º CCW)" for the bugged image.

A different image, taken from the same camera, that displays properly on everything, shows "Orientation – 1 (Normal)".

Unfortunately those photos are family photos so I am unable to upload them here. I can upload additional EXIF information if instructed on how to do so.

(Or, if you happen to have a Canon DIGITAL IXUS 60 from ages ago, you can reproduce this issue by rotating the camera and snapping some shots. Obviously, I don't have that camera anymore so I can't upload test photos.)

The OS that Immich Server is running on

unRAID 6.12.2

Version of Immich Server

v1.66.1

Version of Immich Mobile App

N/A

Platform with the issue

  • [ ] Server
  • [X] Web
  • [ ] Mobile

Your docker-compose.yml content

N/A, not using Docker Compose.
Server is running PostgreSQL 15 with Redis.

Your .env content

N/A

Reproduction steps

1. Upload a photo with the orientation data set in the photo "TIFF" metadata

Additional information

No response

ericswpark avatar Jul 13 '23 04:07 ericswpark

Here is the exiftool output of one of the affected photos:

➜  Downloads exiftool IMG_1177.jpg
ExifTool Version Number         : 12.60
File Name                       : IMG_1177.jpg
Directory                       : .
File Size                       : 179 kB
File Modification Date/Time     : 2023:07:13 13:19:18+09:00
File Access Date/Time           : 2023:07:13 13:19:20+09:00
File Inode Change Date/Time     : 2023:07:13 13:19:18+09:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : Canon
Camera Model Name               : Canon DIGITAL IXUS 60
Orientation                     : Rotate 90 CW
X Resolution                    : 180
Y Resolution                    : 180
Resolution Unit                 : inches
Modify Date                     : 2011:04:28 13:24:18
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/40
F Number                        : 2.8
Exif Version                    : 0220
Date/Time Original              : 2011:04:28 13:24:18
Create Date                     : 2011:04:28 13:24:18
Components Configuration        : Y, Cb, Cr, -
Compressed Bits Per Pixel       : 5
Shutter Speed Value             : 1/40
Aperture Value                  : 2.8
Max Aperture Value              : 2.8
Flash                           : Off, Did not fire
Focal Length                    : 5.8 mm
Macro Mode                      : Normal
Self Timer                      : Off
Quality                         : Superfine
Canon Flash Mode                : Off
Continuous Drive                : Single
Focus Mode                      : Single
Record Mode                     : JPEG
Canon Image Size                : Small
Easy Mode                       : Manual
Digital Zoom                    : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : 0
Camera ISO                      : Auto
Metering Mode                   : Evaluative
Focus Range                     : Auto
AF Point                        : Auto AF point selection
Canon Exposure Mode             : Easy
Lens Type                       : n/a
Max Focal Length                : 17.4 mm
Min Focal Length                : 5.8 mm
Focal Units                     : 1000/mm
Max Aperture                    : 2.8
Min Aperture                    : 5.6
Flash Bits                      : (none)
Focus Continuous                : Single
AE Setting                      : Normal AE
Zoom Source Width               : 2816
Zoom Target Width               : 2816
Spot Metering Mode              : Center
Manual Flash Output             : n/a
Focal Type                      : Zoom
Focal Plane X Size              : 5.84 mm
Focal Plane Y Size              : 4.39 mm
Auto ISO                        : 200
Base ISO                        : 100
Measured EV                     : 7.94
Target Aperture                 : 2.8
Target Exposure Time            : 1/40
Exposure Compensation           : 0
White Balance                   : Auto
Slow Shutter                    : Off
Shot Number In Continuous Burst : 0
Optical Zoom Code               : 0
Flash Guide Number              : 0
Flash Exposure Compensation     : 0
Auto Exposure Bracketing        : Off
AEB Bracket Value               : 0
Control Mode                    : Camera Local Control
Focus Distance Upper            : 0.68 m
Focus Distance Lower            : 0 m
Bulb Duration                   : 0
Camera Type                     : Compact
Auto Rotate                     : Rotate 90 CW
ND Filter                       : Off
Self Timer 2                    : 0
Flash Output                    : 0
Canon Image Type                : IMG:DIGITAL IXUS 60 JPEG
Canon Firmware Version          : Firmware Version 1.00
File Number                     : 120-1177
Owner Name                      :
Camera Temperature              : 26 C
Canon Model ID                  : PowerShot SD600 / Digital IXUS 60 / IXY Digital 70
Num AF Points                   : 9
Valid AF Points                 : 9
Canon Image Width               : 640
Canon Image Height              : 480
AF Image Width                  : 1408
AF Image Height                 : 264
AF Area Width                   : 253
AF Area Height                  : 48
AF Area X Positions             : -253 0 253 -253 0 253 -253 0 253
AF Area Y Positions             : -49 -49 -49 0 0 0 49 49 49
AF Points In Focus              : 4
Primary AF Point                : 4
Thumbnail Image Valid Area      : 0 0 0 0
Date Stamp Mode                 : Off
My Color Mode                   : Vivid
Firmware Revision               : 1.00 rev 1.00
User Comment                    :
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 640
Exif Image Height               : 480
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Related Image Width             : 640
Related Image Height            : 480
Focal Plane X Resolution        : 2844.444444
Focal Plane Y Resolution        : 2840.236686
Focal Plane Resolution Unit     : inches
Sensing Method                  : One-chip color area
File Source                     : Digital Camera
Custom Rendered                 : Normal
Exposure Mode                   : Auto
Digital Zoom Ratio              : 1
Scene Capture Type              : Standard
Compression                     : JPEG (old-style)
Thumbnail Offset                : 5120
Thumbnail Length                : 6564
Image Width                     : 640
Image Height                    : 480
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Drive Mode                      : Single-frame Shooting
ISO                             : 200
Lens                            : 5.8 - 17.4 mm
Shooting Mode                   : Manual
Aperture                        : 2.8
Image Size                      : 640x480
Lens ID                         : Unknown 5-17mm
Megapixels                      : 0.307
Scale Factor To 35 mm Equivalent: 6.1
Shutter Speed                   : 1/40
Thumbnail Image                 : (Binary data 6564 bytes, use -b option to extract)
Lens                            : 5.8 - 17.4 mm (35 mm equivalent: 35.1 - 105.3 mm)
Circle Of Confusion             : 0.005 mm
Depth Of Field                  : 0.10 m (0.30 - 0.39 m)
Field Of View                   : 54.3 deg
Focal Length                    : 5.8 mm (35 mm equivalent: 35.1 mm)
Hyperfocal Distance             : 2.42 m
Light Value                     : 7.3

ericswpark avatar Jul 13 '23 04:07 ericswpark

Same here, but I can provide some images.

immich.zip The archive has three images included, wrong orientation, wrong time, wrong orientation & wrong time.

LancerComet avatar Jul 17 '23 03:07 LancerComet

I can confirm the images posted by @LancerComet is working as expected in v1.64.0

Just a shot in the dark, but could it be related to the change introduced in https://github.com/immich-app/immich/pull/3003 ?

1.64.0 old

1.68.0 new

aksvenk avatar Jul 21 '23 06:07 aksvenk

@brighteyed I think we still need those rotations values to be put back

alextran1502 avatar Jul 21 '23 12:07 alextran1502

im facing exact same issue. I went back to 1.66 to get my sanity back !

MayurAgarkar avatar Jul 21 '23 17:07 MayurAgarkar

I can confirm the images posted by @LancerComet is working as expected in v1.64.0

Just a shot in the dark, but could it be related to the change introduced in #3003 ?

1.64.0 old

1.68.0 new

Hmm, I can't reproduce this issue on main. I guess the rotation may not be detected correctly on quite old instances of Immich when non-numeric rotations (Rotate 90 CW) could be written into database. May I ask you to run metadata extraction job for all the assets? Does it fix the issue?

brighteyed avatar Jul 21 '23 17:07 brighteyed

OK here's what I tried:

Scenario 1

  • Fresh instance of 1.64.0
  • Uploaded images above
  • Orientation is ✅

Scenario 2

  • Fresh instance of 1.68.0
  • Uploaded images above
  • Orientation is ❌

Scenario 3

  • Upgraded scenario 1 to 1.68.0
  • Orientation is ✅
  • Run metadata extraction job and regenerate thumbnails
  • Orientation is ✅

I think this might be affecting users who uploaded assets on builds > 1.64.0 My 'prod' instance started its life on 1.68.0 since I have been a Immich user since yesterday :)

aksvenk avatar Jul 22 '23 02:07 aksvenk

@brighteyed I think we still need those rotations values to be put back

If new uploaded assets are normalized we can also do a one time migration to fix this.

jrasm91 avatar Jul 22 '23 18:07 jrasm91

@brighteyed I think we still need those rotations values to be put back

If new uploaded assets are normalized we can also do a one time migration to fx this.

Yeah, it could be a possible fix if we assume that the problem is in the non-numeric orientation value. But I'm not sure, since there are weird symptoms:

  • I see the correct aspect ratio in the screenshots attached above. That means it is not a problem with the EXIF orientation tag value
  • Related issue (#3367) mentions that on another phone app all the vertically taken images are rotated. So it looks like it is not a web UI issue but a thumbnail generation related one
  • The comment above states the issue is reproducible on a new instance

Unfortunately, I can't reproduce an issue myself on the new v1.68.0 instance or main branch.

brighteyed avatar Jul 22 '23 19:07 brighteyed

@ericswpark, @aksvenk, @LancerComet, @MayurAgarkar Could you please provide more information if possible:

  • If you click on the photo in a web UI, do you see the correct photo orientation in the viewer?
  • Does the photo's bounding box at the main timeline have a correct aspect ratio (I mean it is vertical for "vertical" photos)?
  • What Immich version (the newer the better) doesn't have this issue?

brighteyed avatar Jul 22 '23 19:07 brighteyed

@ericswpark, @aksvenk, @LancerComet, @MayurAgarkar Could you please provide more information if possible:

  • If you click on the photo in a web UI, do you see the correct photo orientation in the viewer?
  • Does the photo's bounding box at the main timeline have a correct aspect ratio (I mean it is vertical for "vertical" photos)?
  • What Immich version (the newer the better) doesn't have this issue?
  1. No.
  2. Yes, but it's a vertical box with horizontal content.
  3. v1.67.2. I'm new to Immich and this is my first version.

@brighteyed

Have a look:

immich

LancerComet avatar Jul 22 '23 20:07 LancerComet

@brighteyed

  1. No.
  2. Yes, but it's a vertical box with horizontal content.
  3. I've had this issue since starting with v1.66.1 I believe. About a couple of days ago I upgraded to v1.67.2 and am still experiencing this issue.

The same as what @LancerComet posted above.

I see there is an update available to v1.68.0. Should I try upgrading to that?

ericswpark avatar Jul 22 '23 23:07 ericswpark

@ericswpark please update to 1.68 and run metadata extraction for all again to see if it fix the issue

alextran1502 avatar Jul 23 '23 02:07 alextran1502

@alextran1502 updated to v1.68 and ran the metadata extraction job, but it didn't fix the issue unfortunately :(

ericswpark avatar Jul 23 '23 02:07 ericswpark

@ericswpark Is there a specific troubled photos that you can share for troubleshooting?

alextran1502 avatar Jul 23 '23 02:07 alextran1502

@alextran1502 after much searching found a photo without faces. I tried deleting it from Immich and re-uploading it (on v1.68) and I get the same bug: IMG_5034.jpg.zip

ericswpark avatar Jul 23 '23 02:07 ericswpark

@LancerComet , @ericswpark

Thank you!

Please attach the generated thumbnail:

  • In DevTools find an img tag. You need its alt attribute
  • The generated thumbnail should be here: ${UPLOAD_LOCATION}/thumbs/<user id>/<the value of the alt attribute.jpeg> image

brighteyed avatar Jul 23 '23 03:07 brighteyed

Apologies if I'm derailing this conversation a bit, but I was wondering why @brighteyed was unable to replicate something so fairly obvious.

Then I realised it might be because I had omitted a piece of information while performing my tests. The instances of 1.68.0, 1.64.0 that were stood up was from imagegenius also called all-in-one.

After following the instructions in the official documentation, the rotation values and aspect ratios were perfect.

Hope this helps with the triage. @LancerComet I'm guessing you are using the all in one image as well?

Screen Shot 2023-07-23 at 2 16 26 pm

aksvenk avatar Jul 23 '23 04:07 aksvenk

@brighteyed Here is the thumbnail image, but it's a webp: 9675cd86-fbb9-4eb8-ad17-2c38b76fad09.zip

@aksvenk Yes I'm using all in one image as well 🙀

LancerComet avatar Jul 23 '23 06:07 LancerComet

@brighteyed Here is the thumbnail image, but it's a webp: 9675cd86-fbb9-4eb8-ad17-2c38b76fad09.zip

@aksvenk Yes I'm using all in one image as well 🙀

Oh, thumbnail has incorrect rotation. @martabal, it seems there is an issue of the AIO image, since I can't reproduce the bug with official docker-compose and in dev environment

brighteyed avatar Jul 23 '23 08:07 brighteyed

Dang. Sorry for the trouble everyone, will be fixed with https://github.com/imagegenius/docker-immich/pull/149

martabal avatar Jul 23 '23 10:07 martabal

I updated to the latest all in one image, everything is back to normal, thank you @martabal !

LancerComet avatar Jul 23 '23 12:07 LancerComet

Thanks for the quick turnaround @martabal!

For the assets that have already been uploaded on the previous version, is there a way I can bring them back to a good state? Running jobs extract metadata, regenerate thumbnails did not work unfortunately.

aksvenk avatar Jul 23 '23 12:07 aksvenk

Thanks for the quick turnaround @martabal!

For the assets that have already been uploaded on the previous version, is there a way I can bring them back to a good state? Running jobs extract metadata, regenerate thumbnails did not work unfortunately.

Browser cache needs to be cleaned up, there is a 24 hours local cache for every single image. Or open browser devtool and select disable cache in network tab, then browse Immich like normal

LancerComet avatar Jul 23 '23 12:07 LancerComet

Thanks @martabal, I can confirm that updating the Docker all-in-one and running the jobs again fixed it for me. Closing this issue.

ericswpark avatar Jul 24 '23 00:07 ericswpark

Hi I'm still facing this issue with wrong rotation in web view. Running version: V.1.101.0 and tried all described in the comments above.

Maybe someone can help me?

dennisfrijlink avatar Apr 07 '24 23:04 dennisfrijlink

Same here with Version 1.101.0 running on TrueNAS in a Kubernetic-App. I rotated the images with https://annystudio.com/software/jpeglosslessrotator/ The Windows Explorer and BandiView are displaying in in the right way.

Nordlicht-13 avatar Apr 11 '24 10:04 Nordlicht-13

Running now version: v1.103.1, but still facing same issue here (on web). I noticed when I open the photo and zoom in the photo rotates to the right angle. But for the previews/thumbnails in the gallery still the same issue.

@martabal maybe any idea this will getting fixed in a (next) release?

Thanks in advance

dennisfrijlink avatar May 03 '24 21:05 dennisfrijlink

In the web you can select a single asset and in the menu there is an option to regenerate thumbnails. Can you do this for the affected file and see if it makes any difference?

jrasm91 avatar May 04 '24 02:05 jrasm91

Hi @jrasm91,

Thanks for your reply. I tried that (several times) but unfortunately that didn't work. The weird part is that when I download the photo (on mobile or desktop) the rotation is right.

dennisfrijlink avatar May 05 '24 13:05 dennisfrijlink