5

I always prefer to keep my images in my library in vector form, so that they can be easily modified or scaled later if needed. However, when I am actually using these pictures in a LaTeX documented, a question arises if there is any need for vector graphics, when they can be replaced by high-resolution lossless raster pictures several times smaller in size? For instance, compare this vector picture saved in .pdf format (147 Kb) with the same high-resolution (1498 x 1498) losslessly compressed .png picture (8.31 Kb): A .png picture

As you see, the difference in picture sizes is nearly 10 times. And the image is pretty simple.

I believe you will not see the difference in the printed document, and you will never really scale the computer version to the point when you see separate pixels.

So is there a point in using larger vector graphics instead of compact raster pictures in LaTeX documents? I don't talk about cases, when vector graphics actually occupies less space than raster (is it so often, by the way?).

P.S. When reading professionally prepared scientific articles, one often encounters vector pictures. If articles get bigger this way, why would the professionals use them?

  • 6
    A 147 Kb vector graphic representing that image is woefully inefficient. – Ian Thompson Apr 2 '15 at 20:40
  • 2
    @Szczypawka: This image should ideally only consist of 43 objects: 42 grid lines, and the green polygon. The PDF you linked to consists of 400 different objects, which include a lot or redundant information (each grid line is drawn four times, for example). I recreated your image in Inkscape and saved it as a PDF: It takes up only 1.47 kB we.tl/yIhVchD8aQ – Jake Apr 2 '15 at 20:52
  • 3
    @Jake --- that beats my 2.9K xfig version! I think the original file was created by Adobe Illustrator, which is the work of Satan. – Ian Thompson Apr 2 '15 at 20:54
  • 1
    OTOH, really high resolution images (inserted in a PDF) take a long time to download. – John Kormylo Apr 2 '15 at 20:57
  • 3
    I'm voting to close this question as off-topic because it asks about the use of vector graphics in PDF compared to bitmap graphics in PDF, which is not related to TeX. – Martin Schröder Apr 3 '15 at 13:10
5

For some complex images such as contour plots with very large numbers of differently shaded regions, bitmap formats may work better than vector formats. However, vector formats are always better for simple images consisting of a few lines and polygons.

Now vector formats use sequences of geometrical instructions to tell the computer how to construct the image. This is unlikely to be done in an optimal way, but the inefficiencies caused by programs such as gnuplot and xfig are rarely worth worrying about. Mostly they are caused by redundant definitions at the top of the file, amounting to a few kilobytes. However, Illustrator is notorious for filling vector images with large amounts of useless garbage (a similar issue has been discussed here before). Sometimes it is possible to simply delete this; if you post an eps version of your image I will try (I can't get your pdf version to convert to eps properly).

Ultimately, using Illustrator is like crossing the Misty Mountains by going through the Mines of Moria --- don't do it unless you have no other choice. Here is a 719 byte eps version of your image.

%!PS-Adobe-2.0 EPSF-2.0
%%Title: green_thing.eps
%%BoundingBox: -2 -2 382 382
/L{lineto} bind def
/M{moveto} bind def
/N{newpath} bind def
/R{rlineto} bind def
/vline{N 0 0 M 0 380 L stroke} bind def
/hline{N 0 0 M 380 0 L stroke} bind def
0.5 setlinewidth
0.75 1.0 0.61 setrgbcolor
N 160 20 M
80 0 R
2{0 20 R 40 0 R} repeat
2{0 40 R 20 0 R} repeat
0 100 R
2{-20 0 R 0 40 R} repeat
2{-40 0 R 0 20 R} repeat
-100 0 R
2{0 -20 R -40 0 R} repeat
2{0 -40 R -20 0 R} repeat
0 -100 R
2{20 0 R 0 -40 R} repeat
60 0 R
0 -20 R
40 0 R
closepath fill
0 0 0 setrgbcolor
18{20 0 translate vline} repeat
-360 0 translate
18{0 20 translate hline} repeat
0 -360 translate
N 0 0 M 0 380 L 380 380 L 380 0 L closepath stroke
showpage
%EOF

green thing

1

When saving PDF files from Adobe Illustrator you can specify in the save dialog unter Adobe PDF Preset to use Smallest File Size. Use this for the files that go into production but keep another copy for editing. This also applies to EPS files saved from Illustrator.

enter image description here

  • 2
    Thank you Christian, but the .pdf above was already obtained with this setting. I have already found out that Illustrator saves other objects (probably, brushes and swatches, which go into "Document Overhead"), which make the file larger and are not excluded by the "Smallest file size" setting. I have found no way to get rid of these object from inside Illustrator, and you have to go to Acrobat Pro for that. However, in Inkscape it's all smooth and natural. – Dr_Zaszuś Apr 3 '15 at 9:08
  • I looked at your file with cpdf, a command-line tool for PDF processing, and managed to shrink it to 121kB. While it does have an option to remove unused code, it didn't seem to find the overhead. – Christian Lindig Apr 3 '15 at 9:34
1

If you already know what resolution you're going to show and print your document in, the raster graphics are fine. You are the master of your own destiny!

Keeping it in vector format means that whoever prints it or views it should be able to see it without any ugliness. In most cases the image is pixelated before it's viewed or printed anyway

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.