I want to create a pdf document from images of different size and I fit each image to the text dimensions to include them in the document, with

\includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{file.jpg}

The problem is that these images are very enormous: 160MB in total; and this size is kept in the pdf output (160.9MB), but I don't need so much pixel information since I resize each image.

How can I exploit the resizing of each image to earn space?

  • 6
    Instinct tells me that LaTeX is not an image/graphics editor, and usually just dumps the image content in the output without modification. As such, some preprocessing using an external application is your best bet (for example, GIMP or Imagemagick).
    – Werner
    Feb 26, 2013 at 17:29
  • 4
    In addition to resample/resizing (using external tools as Werner suggested) I would also change the jpeg quality. Reducing it to 75% is usually few noticeable (specially on screen), and reduces dramatically the image size.
    – JLDiaz
    Feb 26, 2013 at 17:41

2 Answers 2


Well, PDF is a scalable format so whether or not you see these pixels depends on your output resolution, that is the screen resolution and zoom level of your PDF viewer or the paper size and dpi number of your printer. Both can be insanely high (you can apparently buy a printer with 4800 dpi in one dimension for under 100 €/$/£ and going to 6400 % in Adobe Reader on a 4K or Retina display also needs some serious resolution in your non-vector graphics).

I mean, remember, this was native screen resolution once:


Long story short: TeX can't know what resolution you are going to need, only you can (and sometimes that's difficult enough to decide). If say you only need 72 dpi for screen reading (please don't but it's your decision) then multiply that with the size of your image in inch and you know what to tell gimp or whatever software of your choice (see the comment by Werner). Also, smart usage of JPEG parameters as JLDiaz suggested might be a very good idea.


As the other suggested you can do some pre-processing on your images. This can be done with any tool you're comfortable with that can batch-process several files at once.

If you use ConTeXt you can hook this into the graphic inclusion routine very easily. Probably you can do this in LaTeX as well. Here is an example which uses graphicsmagick to reduce the image size and compress the image.

  figures.converters.jpg = {
    degradejpg = function(oldname,newname)
      os.execute(string.format('gm convert -size 80%% -quality 20%% "%s" "%s"',oldname,newname))

  %% unmodified inclusion
  \externalfigure [hacker]

  %% reduced size and higher compression
  \externalfigure [hacker] [conversion=degradejpg]


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .