# [Tex/LaTex] Image from \includegraphics showing in wrong image size

dimensionsgraphicsresolution

When I use the following to embed an image:

\begin{figure}[htb]
\centering
\includegraphics{my_image}
\caption{blaaa}
\label{fig:blaaa}
\end{figure}


whereas my_image is a JPG file, the image doesn't show in the correct format. It gets displayed bigger than the original my_image.jpg itself is and thus the quality is quite bad. Even when I do

\includegraphics[width=300px,height=100px]{my_image}


for a picture my_image.jpg which is exactly 300px*100px in size, it gets displayed in greater size and stretched 🙁 I have no header declaration which change \includegraphics settings.
I would like images with plain \includegraphics{my_image} to be displayed in their REAL size.

When you take a screenshot or export a figure from Matlab as a rasterised image,usually the resulting image file will not contain any resolution information (or "pixel density", usually measured in "dots per inch", or "DPI") in its metadata. When you include such an image in a LaTeX document using \includegraphics, a resolution of 72 DPI will be assumed. For example, that means that a screenshot that has a size of 1440x900 px will have a width of 1440 px / 72 px per in = 20 in = 51 cm in your PDF or DVI, so it will most likely be too big for your document. A computer monitor with a horizontal width of 15 in (= 38 cm) that is operated at a screen size of 1440x900 px has a resolution of 1440 px / 15 in = 96 dpi. If you want your screenshot to have the same size (in this case a width of 38 cm) both on your computer screen and in the printed document, you need find a way of letting LaTeX know that the resolution of the image is 96 DPI. There are a number of ways you can do this:

As an option to includegraphics:
If you're compiling your document using pdflatex, you can specify the resolution of the image by loading it using \includegraphics [resolution=<resolution in DPI>] {<filename>}. This will only work if no resolution information is included in the image.

By setting the image metadata using GIMP:
Go to Image -> Scale Image... and adjust the X and Y resolution after making sure pixels/in is chosen in the drop down menu. Then save your image.

By setting the image metadata using IrfanView:
In IrfanView 4.30, you can click Image - Information (or press I) to show the metadata of the image. The fifth row is called Resolution and should contain two fields in which you can set the horizontal and vertical resolution in dots per inch. By pressing the button Change, the new resolution will be set. The "physical" size of the image in cm and inch, which is obtained by multiplying the size in pixels with the resolution, is shown in the eigth line, called Print Size (from DPI). You can then include the image in your LaTeX document by calling \includegraphics {<filename>} without any extra options.

By setting the image metadata using ImageMagick:
On Linux systems, frequently the ImageMagick programs are already present or can easily be installed. You can then set the resolution information by calling convert <original file name> -density <resolution> -units PixelsPerInch <new file name> in a shell. You can then include the image in your LaTeX document by calling \includegraphics {<filename>} without any extra options.