Graphics, Figures & TablesHow to crop images to reduce PDF size

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
120
Posts: 2
Joined: Tue Mar 09, 2010 10:04 pm

How to crop images to reduce PDF size

Post by 120 »

To crop an image, the command \includegraphics*[clip=true, viewport=0 0 10 10]{...} looks great, but the image is not really cropped.
The image at full resolution is included in the PDF and can be accessed by copy/past.

Of course, I can first reduce/crop my image with Gimp, but I'm looking for alternatives solutions.
Is it possible to really crop the image with LaTeX, and reduce the PDF size?
(I have the same problem with reduced picture[width=10%] )

Maybe with TikZ ???

Tks,
Vincent

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to crop images to reduce PDF size

Post by localghost »

120 wrote:[...] Is it possible to really crop the image with LaTeX, and reduce the PDF size? [...]
As far as I know this is not possible. LaTeX processes an external graphics file as is and doesn't care about its size.
120 wrote:[...] Maybe with TikZ ?[...]
I don't see where pgf/tikZ could be helpful in this case.


Best regards and welcome to the board
Thorsten
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to crop images to reduce PDF size

Post by frabjous »

The image at full resolution?

This puzzles me. If this image in question is a raster graphic, it's not clear to me why you'd need to use the PDF format for it, nor what the problem would be with cropping it with the GIMP.

If the image is vector based, then the concept of "resolution" doesn't really apply to it. (Or at least, it hardly effects how big the file is.)

Where and how did you acquire this PDF image? If you only need part of it, the best thing to do would be to go back to the source and delete the stuff from it that you're not going to use before exporting to PDF.

If you only have it in PDF format, and it's vector based, that's a bit tricky. Your latex distribution probably comes with the pdfcrop tool -- though that's mainly used for removing whitespace, which will not have an appreciable effect on file size.

I sometimes use the pdfmanipulate command line tool that comes with calibre for cropping parts of PDF beyond whitespace, but I've never really paid any attention to its effect on the file size.
120
Posts: 2
Joined: Tue Mar 09, 2010 10:04 pm

Re: How to crop images to reduce PDF size

Post by 120 »

My images are many png files 1024*768, come from an external tool.
I want to include small thumbnails in my PDF.
I can't use Gimp (or ImageMagick) because I need some others informations (\pagewidth, \textwidth, ...) which are only available in Latex.

You said that latex is not a graphic tool and that it use images as is !
But with tikz, the command
\node[cm={....}]{\includegraphics{...}};
will really transform the image.
A rectangle will become a parallelogram.
The images stored inside the final PDF is transformed.

I can use it for resizing, but not for cropping.

Thanks for your time.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to crop images to reduce PDF size

Post by frabjous »

120 wrote:I can't use Gimp (or ImageMagick) because I need some others informations (\pagewidth, \textwidth, ...) which are only available in Latex.
What I had in mind was that you would use the GIMP to create cropped or edited versions of your images, and then you can use LaTeX to insert the edited versions in your document.
Post Reply