Image height and width are inverted in Ubuntu vs Windows

ng flag

Given this image, I tried to read the image height and width in pixel values, but they are inverted on my Ubuntu PC (Ubuntu 20.04.3 LTS). When I open the image to visualize it, is clear that height > width.

Windows gets it right though:

enter image description here

So width should be 336 and height 448.

On Ubuntu I tried (one needs imagemagick installed, so if needed: sudo apt-get install imagemagick):

identify -format '%h %w' 2075125.jpg 
# gives 336 448 and it should be 448 336

I also tried other tools, thinking that maybe is an imagemagick issue:

sudo apt install libimage-size-perl # for imgsize

imgsize 2075125.jpg
# width="448" height="336" # same issue


sudo apt install libimage-exiftool-perl

exiftool -ImageHeight -ImageWidth 2075125.jpg
# Image Height                    : 336
# Image Width                     : 448

I don't understand what is the issue here and I would appreciate help.

Nmath avatar
ng flag
I'm pretty sure that Windows will "rotate" an image and store that rotation information on metadata in another file that is not the image itself. You're getting accurate details about the file's actual metadata from the tools you are using in Ubuntu. It's Windows storing metadata elsewhere that is the "problem". Looking at the image you posted, it seems likely that the rotation orientation could be different in Windows.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.