8

I inserted a picture in LaTeX, but it rotated my picture. Why?

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\includegraphics[width=0.5\textwidth]{1.jpg}
\end{figure}
\end{document}

All the files are here:files

1

2 Answers 2

17

The meta data of your image contains the tag "orientation" with the value "rotate 90 CW". This value is obeyed by most image viewers, but, as it seems, not LaTeX. Your best approach is probably to rotate that image yourself, as you have found out.

3
  • 1
    Interesting. So the keyword of relevance seems to be Exif. Do you know, if there’s a tool, which can correct the orientation, e.g. as a batch run?
    – MS-SPO
    Apr 13 at 15:53
  • Ah, I see it might be the program exiftool exiftool.org , which could be called by Latex via package bashful: tex.stackexchange.com/questions/296767/…
    – MS-SPO
    Apr 13 at 16:04
  • 3
    @MS-SPO if you're looking for a tool to batch rotate a lot of images based on exif data, ImageMagick is a very versatile and powerful option: stackoverflow.com/questions/19456036/…
    – anjama
    Apr 13 at 21:01
6

It seems to depend on the jpg-File. When I save your foto as png without applying any rotation to it using Paint.net, it seems to be as expected.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
  \begin{figure}
    \includegraphics[scale=0.05]{1.jpg}
    \caption{The jpg-image}
  \end{figure}
  
  % --- saving the jpg as png with Paint.net
  \begin{figure}
    \includegraphics[scale=0.05]{1b}
    \caption{The png-image}
  \end{figure} 
\end{document}

jpg and png on one page

P.S.: According to comments and answer I tried this site http://exif.regex.info/exif.cgi, which provides the Exif-tool online, to read out metadata contained in your photo 1.jpg, see screenshot.

As you can see, it's a pretty long list, which dependes on the photo, AND it sets the flag to "Rotate 90 CW". In contrast this flag is missing in the png I created.

BTW: I now know your smartphone model, when and where you took the photo etc. ... you just shared it.

Excerpt of Exif-data of metadata in 1.jpg

3
  • But when I opened the jpg-file, it is as your figure 2. Why in Latex, it becomes figure 1 in your answer?
    – Y. zeng
    Apr 13 at 15:01
  • I confirm your observation and have no idea why this is, should or could be ... Anyway I showed you a workaround :) // If you watch the Linked and Related columns to the right, or search here, you'll see, you're not alone. And you'll find even more workarounds there. // Probably it's relevant what's inside the jpg on binary level, not what programs make of it, like explorer or photo viewers ...
    – MS-SPO
    Apr 13 at 15:12
  • 1
    I try to solve this problem by rotate it: \includegraphics[angle=270,width=\textwidth]. But it is a little trouble.
    – Y. zeng
    Apr 13 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.