Graphics, Figures & TablesWhat size to compress images to?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

What size to compress images to?

Post by RiW »

Hi,

I've recently started using Latex and adding graphics with the graphicsx package. I've found that Latex is rather poor at upscaling images so I've tended to include image files with a larger resolution than I expect is required. The problem is, my PDF files are now massive and impractical to email out. This got me wondering: what size is best to include images?

Say I want an image to be as wide as the text, is the following thinking correct?

Assumptions
Image Width = 18cm (max)
Printer resolution = 150 dpi (is the the average printer resolution?)
1 inch = 2.5cm

So,
18cm = 7.2 inches = 1080 dots....
IE - My images should have a width of around 1000 pixels?

Thanks!
Last edited by RiW on Wed Sep 01, 2010 7:51 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: What size to compress images to?

Post by meho_r »

What purpose will your document serve? Will it be send for printing or reading from screen? The best way is to do some planning before including any graphic material. So, if your text width will be 18cm max, it is the best way to prepare your image (in an image editor like GIMP or Photoshop...) to fit that dimension (or to be a little bit larger) and set the resolution in the editor (about 300 dpi or more for printing (150dpi is an absolute minimum; some people recommend 267dpi), but 72 dpi is probably enough for screen reading; you may try different values though to see which one fits your needs). And, not to forget, never scale a bitmap image (png, jpg etc.) above 100% since that leads to apparent loss of quality.
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Re: What size to compress images to?

Post by RiW »

Thanks for that.

I'm writing a report that will be printed and also emailed out, so I suppose I'll have to keep the high quality images. Unless there's a way / package to create PDFs optimised for each purpose?

Also, did my rough calculation method sound right? i.e. dpi = number of pixels in a one inch line
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

What size to compress images to?

Post by localghost »

RiW wrote:[…] Also, did my rough calculation method sound right? i.e. dpi = number of pixels in a one inch line
You have to take the relation between postscript point (also called big point) and pixel into account. Therefore pixel based graphics have to be scaled to three quarters of their size for proper appearance in the final output (see Forum Search for details, keyword »postscript point«).


Thorsten
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

What size to compress images to?

Post by meho_r »

RiW wrote:Thanks for that.

I'm writing a report that will be printed and also emailed out, so I suppose I'll have to keep the high quality images. Unless there's a way / package to create PDFs optimised for each purpose?
Yeah, it is possible. You may use different file types for different purpose (but with same names), let's say, high-resolution .png files for printing, and low-resolution .jpg files for reading from screen. Now, all you have to do is to omit the extension of the picture when including it in the document, e.g., use: \includegraphics{my_picture} instead of: \includegraphics{my_picture.png}.

To decide which format should be used when compiling your document, you may change the extension list. Add the following code into your preamble:

Code: Select all

\DeclareGraphicsExtensions{.png,.jpg,.pdf}
Pay attention not to forget any extension you're using in your document or you'll get an error message. Priority is decided by the order of extensions specified. So, when you need to compile the document for printing, put .png first in the list. When you need to compile the document for reading, put .jpg first.

There is also another way: keep pictures in two different subfolders, e.g., A and B, then use a custom command, something like this:

Code: Select all

\newcommand{\mypic}[1]{\includegraphics{./A/#1}}
Now, use \mypic command (e.g. \mypic{my_picture}) for including all your pictures and just change A in the custom command with B when you need those files from subfolder B to be included instead of those from subfolder A.
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Re: What size to compress images to?

Post by RiW »

Fantastic - many thanks meho_r... exactly what I was looking for! Will give it a go now.

Thanks again!
jiyahana

What size to compress images to?

Post by jiyahana »

For optimizing your images while keeping quality, you could also try a tool like image compressor. It allows you to adjust image sizes without compromising clarity, perfect for managing different PDF output sizes for print or screen. This way, you maintain high-quality visuals but with smaller file sizes, making them easier to share.
Post Reply