When I use the following to embed an image:


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


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.

  • 4
    Your picture probably doesn't have the correct (or any) resolution information set, which is why it will appear scaled. See the answer to How to Include Picture in Original Size Into Document Page on Centre for one way of fixing this. – Jake Jun 26 '11 at 12:37
  • 1
    It shouldn't be forgotten that px dimensions in pdftex have little to do with the resolution of included images. The default value of 1px is given by 72px = 1in. – egreg Jun 26 '11 at 13:04
  • 2
    @Marc: IrfanView just displays the image at the natural resolution of the computer screen, so one image pixel is one screen pixel. LaTeX can't do that, because there is no equivalent concept of a natural resolution in a print document; instead it assumes the image to have a resolution of 72 pixels per inch if no other resolution information is provided in the metadata of the image (just providing width=300px,height=100px does not provide resolution information). – Jake Jun 26 '11 at 13:44
  • 1
    @Marc: On a side note, you can notify people of comments you write; see meta.tex.stackexchange.com/questions/598/… – Jake Jun 26 '11 at 14:04
  • 1
    @MarcEdlo let us continue this discussion in chat – Jake Jun 26 '11 at 14:05

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.

  • 1
    Also using Phil Harvey's ExifTool (here in GNU/Linux): exiftool -xresolution=72 -yresolution=72 some.jpg. Check it with exiftool some.jpg|egrep ' Resolution'. – joharr Mar 8 '15 at 19:42
  • 1
    @cyberSingularity are you using pdflatex? In my case, [resolution=..] also has no apparent effect. I'm using the sublime text plugin latexing which uses latexmk which (I think) users pdflatex (and the output is a pdf..). – drevicko May 21 '15 at 23:45
  • It is defined in pdftex.def: %% * Option "resolution" (graphicx/experimental): this sets %% \pdfimageresolution, see pdfTeX documentation. – David Carlisle May 22 '15 at 8:56
  • @DavidCarlisle, Jake: Aha, thank you. I had missed that as it is not in the graphics folder. I will delete all my incorrect comments now... I have retested and it does indeed work for me. Perhaps I had included the same image with multiple different resolutions when I originally tested, which does not work. – cyberSingularity May 22 '15 at 9:37

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.