Image tilted by 90 degree during view


Refer the below mentioned code

import matplotlib.pyplot as plt

image_path = “c://image_test/coco/nipun.jpg”
image_tensor_int = read_image(str(Path(image_path)))
plt.imshow(image_tensor_int.permute(1, 2, 0))

The view of image is shown with 90 degree rotation. However, when i open the image in Microsoft Paint and save the image, the view is correct
I tried to determine if there anything different with the format of the image . But could not identify any different between original image vs image saved by Microsoft Paint

I cannot reproduce the issue by downloading your image and using:

image ='./tmp.jpeg')

x = image.permute(1, 2, 0)

plt.imshow visualizes the image in the same way you’ve posted it here.

Thanks… for your response. I checked the meta data for my image in an online tool. I could see the following
Orientation Rotate 90 CW

However, when this images is transmitted via any medium like Whatsapp, online portal it seems this property is deleted. Once the meta data is deleted the behavior is ok in Pytorch
Here is how this is happening

  1. Clicked the photo from my camera – View is ok
  2. Uploaded the photo to Google photos and download again – An exif property is added (Orientation: Rotate 90 CW)
  3. Transmit the image via Whatsapp, onlineportal - Orientation property is again deleted from image

There is one more important point. It looks like pytorch respects the orientation property. But opencvs does not respect this property. Hence, if any project is a mix of opencvs and pytorch then the output could be confusing
Is there a way to instruct pytorch to ignore orientation exif meta data

I believe would call into libjpeg for your provided image and it seems that the meta data was already removed from the uploaded picture in your first post.
Could you provide the image containing the meta data and instructions how to reproduce the issue?

It looks like that the meta data is deleted when i uploaded image to this portal. Can you try to download the image from

I have uploaded the image on Ubuntu server. This should ensure there is no change to Meta data
I tried to use the code mentioned by you and i am able to reproduce the issue i.e. the view will be rotated by 90 degree
If you will upload the same image on this portal then the image view will be correct i.e. there is no rotation of 90 degree

Unfortunately I’m unable to download the entire picture, as the download times out after a while.
I’ll try to load it a bit later as maybe the server has some trouble.

I just checked again. All looks ok. Can you please re-try?

Still doesn’t work. In any case, since you can reproduce the issue using my code snippet, there might not be the need to download it again. As a workaround you could try to wipe the meta data as I guess that libjpeg might (rightfully) respect it.

ok thanks…I will write some additional code to remove the meta data before any further processing