Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a report that includes a results section with a lot of generated images. These images are .png files. Judging by the file size of the resulting pdf, these images are included in their entirety, even when they are resized and clipped (trimmed).

An image of 4MB will increase the size of the resulting pdf by about 4MB, regardless of the fact that I only show half of the image and the image is greatly downscaled.

I'm using:

\includegraphics[keepaspectratio,%
    width=0.5\linewidth,height=6cm,%
    clip,trim=700 0 700 300]
    {../results/img01.png}

In my case, this leads to a pdf that is over 100MB. How can I tell LaTeX to compress the images or discard the parts that are not shown?

I know I can print it afterwards with a pdf-printer and it will reduce the file size to about 20MB (which is a lot smaller than 100MB) but I would rather not have this intermediate step. Why can't pdfLaTeX reduce this file size too?

share|improve this question
    
What kind of images are these? Could you opt for a pure vector-format version of these images? It would help if you could provide an example. –  pluton Jun 16 at 19:21
    
These are dental radiographs that are being processed by some code. Vector-format is not possible, but I could rerun my code and save them in a more compact format. Since the report does not need full detail images, I guess even a lossy format like .jpg might suffice. But I would like to hear if there are solutions, because next time I need something similar, I might not have this luxury. –  neXus Jun 16 at 19:40
2  
See tex.stackexchange.com/q/56936/21344 --- pdflatex cannot directly modify the included image data. You must either pre-process the included png files or post-process the resulting pdf (one option: tex.stackexchange.com/a/19047/21344). –  Paul Gessler Jun 16 at 20:01

1 Answer 1

A TeX compiler is not an image processing program. The image is just included in total. Trimming/clipping is applied via PDF (PostScript) operators without changing the image.

Load the image into an image processing program (gimp or many other), remove the unwanted parts there. Depending on the image, it could also be downscaled or exported in a different format such as JPEG (lossy). Then it also simplifies the including in LaTeX, because option trim or viewport with its coordinates are not needed any longer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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