Image tilted by 90 degree during view

Neelam_Jain: <p>Hello,</p>
<p>Refer the below mentioned code</p>
<p><em>import matplotlib.pyplot as plt</em></p>
<p><em>image_path = “c://image_test/coco/nipun.jpg”</em><br>
<em>image_tensor_int = read_image(str(Path(image_path)))</em><br>
<em>plt.imshow(image_tensor_int.permute(1, 2, 0))</em></p>
<p>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<br>
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<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/4/e488604255fcdab196048ec735362d636269987e.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/e488604255fcdab196048ec735362d636269987e" title="nipun"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/4/e488604255fcdab196048ec735362d636269987e_2_229x500.jpeg" alt="nipun" data-base62-sha1="wBH2WFAbq9jTjnKb6VpoHQ1Kp54" width="229" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/4/e488604255fcdab196048ec735362d636269987e_2_229x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/e/4/e488604255fcdab196048ec735362d636269987e_2_343x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/e/4/e488604255fcdab196048ec735362d636269987e_2_458x1000.jpeg 2x" data-dominant-color="7D7A74"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">nipun</span><span class="informations">1920×4189 361 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>I cannot reproduce the issue by downloading your image and using:</p>
<pre><code class="lang-python">image = torchvision.io.read_image('./tmp.jpeg')

x = image.permute(1, 2, 0)
plt.imshow(x.numpy())
</code></pre>
<p><code>plt.imshow</code> visualizes the image in the same way you’ve posted it here.</p>

Neelam_Jain: <p>Thanks… for your response. I checked the meta data for my image in an online tool. I could see the following<br>
Orientation	Rotate 90 CW</p>
<p>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<br>
Here is how this is happening</p>
<ol>
<li>Clicked the photo from my camera – View is ok</li>
<li>Uploaded the photo to Google photos and download again – An exif property is added (Orientation: Rotate 90 CW)</li>
<li>Transmit the image via Whatsapp, onlineportal - Orientation property is again deleted from image</li>
</ol>
<p>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<br>
Question:<br>
Is there a way to instruct pytorch to ignore orientation exif meta data</p>

ptrblck: <p>I believe <code>torchvision.io</code> would call into <code>libjpeg</code> for your provided image and it seems that the meta data was already removed from the uploaded picture in your first post.<br>
Could you provide the image containing the meta data and instructions how to reproduce the issue?</p>

Neelam_Jain: <p>It looks like that the meta data is deleted when i uploaded image to this portal. Can you try to download the image from <a href="https://miniimagesvideos.com/nipun.jpg" rel="noopener nofollow ugc">https://miniimagesvideos.com/nipun.jpg</a></p>
<p>I have uploaded the image on Ubuntu server. This should ensure there is no change to Meta data<br>
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<br>
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</p>

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

Neelam_Jain: <p>I just checked again. All looks ok. Can you please re-try?</p>

ptrblck: <p>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 <code>libjpeg</code> might (rightfully) respect it.</p>

Neelam_Jain: <p>ok thanks…I will write some additional code to remove the meta data before any further processing</p>