Why does Nextcloud rotate my photos to an incorrect orientation?

I am using Nextcloud 24.0.4 and Photos 1.6.0.

Today I uploaded a bunch of photos, all of size 800x600 or 600x800. Before uploading them I rotated the ones that needed rotation to be viewed correctly and when I view them on my laptop with a viewer program, they are oriented correctly. But after uploading these files, when viewing them in my Nextcloud instance on my VPS, many of the photos are displayed 90º out ofthe correct position. Why does Nextcloud rotate them like that?

Have you really edited the orientation of the image in the file or only the way it got displayed on the screen? Afaik, Nextcloud relys on the information stored in the image file.

1 Like

I opened them in GIMP, resized them to 800x600, then rotated the image to the orientation I wanted (so up is up) and exported to a new file. When I opened them in Ristretto viewer before altering then, the pics were 90º out of correct position and very large. When I open the exported file, the pics are the new size with the correct orientation.

Rotation information is also stored in the EXIF data of the picture. GIMP most likely mentioned this to you if it contained EXIF rotation when you opened it. My guess is that the EXIF rotation has either been stripped or added or is incorrect, and that one or more of the programs in play are doing something unexpected as a result.

What happens if you download one of the rotated pics and open it in GIMP?

I downloaded one of the photos from my Nextcloud installation. When I opened it in Ristretto it opened in the correct orientation. When I opened it in GIMP, as you said, it offered me the chance to keep the original orientation or rotate it. Clicking the option to keep the original orientation and NOT rotate it opens the image in the correct orientation. see screenshot
gimp

I also included a screenshot of the file’s properties from Nautilus (my file manager program). Largura=width Altura=height
nautilus

As I suspected then, somewhere in your editing, the picture has ended up with incorrect EXIF rotation. This EXIF data is originally added by the camera when the picture is taken. For example, an iPhone always saves pictures in the same orientation, but then adds EXIF data saying to rotate it to match how the phone was held when it was taken. It sounds like maybe Ristretto is ignoring the EXIF rotation saved in the file.

When you export the image from GIMP, there’s a checkbox that says whether to save EXIF data. If you uncheck it, the rotation data would be removed. Try that and see if it works as expected.

The best you can do to understand is to use exiftool. Output is like this:

exiftool foo.jpg

Image Size : 3072x4096
Orientation : Horizontal (normal)

So you can understand both the real XY setting of the image, and the metadata for the viewer rotation (Orientation)

I am so sorry for wasting your time by giving you incorrect information. I originally uploaded some photos I had altered in GIMP. But later when I had more than 20 photos to upload, I resized them and rotated them as batches in a terminal. I DIDN’T use GIMP for those files. I see that the files I edited in GIMP are displaying correctly, but the ones I did as a batch are not. Again, I’m sorry for giving you the wrong information.

But while I’m here, do you know if there’s a way to ensure the correct display of the images if I rotate them in a batch on the command line? The command I used is, “*for photo in .jpg ; do convert $photo -rotate 90 $photo ; done” (without the quotes)? Or do I have to alter them individually in GIMP?

Thanks onlyscience. Please see my last response to KarlF12

I think what I was getting at is still the same. Maybe this convert tool is rotating the image pixels but leaving the EXIF data as-is (telling other programs it still needs to be rotated when displayed).

If you want to rotate them physically, you’ll also need to clear the EXIF property saying it needs to be rotated again, otherwise you’ll still get this inconsistent behavior. I think you can do that with exiftool and add the extra command to your script.

I looked at the exif data for the files using exiftool and it indicated orientation of 90ºCW. I changed that using the command exiftool -orientation#=1 photo_name.jpg. I was also able to do this for all of the photos in the same directory by using the wildcard instead of photo_name, like this: exiftool -orientation#=1 *.jpg.

Thanks for your help. I learned some new things about image files from you and I appreciate it.

3 Likes

Sure, no problem. I think I learned about EXIF tags the same way. :laughing: