[Tex/LaTex] How to decrease the file size of pdf with a lot of (clipped and downscaled) png images

cropfile sizegraphicspng

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?

Best Answer

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.