I would like to embed a scanned document into a PDF document.

The source picture is about 300 kB.
If I use the convert command, the PDF has a size of 30 MB, and with GIMP, 3 MB.

Here the resulting file sizes of various commands. The only way I found to get a reasonable PDF file size is to first convert to JPEG, then to PDF.

scanimage -p --mode Color --format tiff -x 205 -y 297 > image.tiff      | 25.5
convert -quality 30  -compress Zip image.tiff image-zip.pdf             | 32.2
convert -quality 30   image.tiff image.pdf                              | 12.1
convert -compress Zip image.tiff image-wq-zip.pdf                       | 11.1

convert image.tiff image.jpg                                            | 2.3
convert -quality 30 image.tiff image.jpg                                | 0.34
convert -quality 30 -define jpeg:extent=200kb image.tiff image-200.jpg  | 0.19

convert image-200.jpg image-jpg.pdf                                     | 0.19
  • 1
    Because you probably "raster-ed" the image with a different resolution or it was changed the compression level. Can you give more information about the pdf and the command used? in which format was the image? You can have some hints with identify -verbose yourfile.pdf and identify -verbose yourfile.jpg (assuming jpg as source format). It can be changed even the colorspace. – Hastur Jan 28 '16 at 16:57
  • 2
    Try using the compress option in the command, e.g. -compress Zip. More information is here: imagemagick.org/Usage/formats/#pdf_options – James P Jan 28 '16 at 17:17
  • It is mainly the compression algorithm. Try to extract the images from the one coverted by gimp, (g.pdf), the one with convert s.tif c.pdf and the last with convert s.tif -compress Zip z.pdf: you can use pdfimages g.pdf g, pdfimages c.pdf c and pdfimages z.pdf z. You will find g-000.ppm, c-000.ppm and z-000.ppm that are almost the same. You can compare (subtract) to stress the differences... – Hastur Jan 28 '16 at 17:48
  • with -compress Zip, the file size is 12Mo. – Gael Jan 28 '16 at 17:58
  • And with -compress jpeg ? I've tried with an uncompressed tif and I found the same quality and size for the gimp and -compress zip ones. If you should post some link to the image (or to another one that generate the same behaviour) we can do some attempt... – Hastur Jan 28 '16 at 18:33

The main reason in my opinion is that PDF stores compatibility settings which could increase your file size. If you use Adobe Acrobat, you can use reduce PDF file size and remove these settings.

Or you can embed your image in Word. Just insert the image and save the file as PDF, but choose 'Minimum size (publishing online)' when you select PDF from 'Save as type' menu.

Compatibility settings is what makes PDF viewable and printable at a reasonable quality and perhaps they are the reason behind PDF widespread.

  • "minimum size" would work, but its not compatibility, it is because it downsamples to 72ppi and uses JPG compression when embedding the images. – Yorik Jan 28 '16 at 19:30
  • @Yorik Indeed, it's about compression in this case. But generally speaking, if you use Adobe Acrobat Pro: File -> Save as -> Reduced size PDF, you'll be prompt to select Acrobat Version Compatibility which are presets for image compressions, fonts embedding, etc. which can be set in the optimised PDF command from File menu. – Sanny Jan 28 '16 at 22:49

PDFs always have an implicit paper size, such as 8.5x11 inches and typically export at 250-300ppi.

An 8.5x11 sheet of paper is going to be about 2550x3300 pixels.

An RGB color image for screen is 3 "channels" (greyscale images), and CMYK is 4. Greyscale is single channel.

For "normal images" a pixel is 1 byte per channel.

So 2550x3300x3/1024/1024 = about 24MB for RGB (32MB for CMYK) (uncompressed).

Sounds about right. Jpeg compression gets you a lot further but at the expense of quality as it destroys data during the compression process.

Note that placing an image of a document in a PDF container at 0,0 origin with a page size=image size does nothing for you. Its like wrapping a present in another present.

If you are scanning B&W documents, you can cut the size by 1/3 initially by not using RGB mode.

Be aware that non-rgb Jpeg images are not universally supported however.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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