[pstricks] jpg versus eps

Werner Grundlingh wgrundlingh at gmail.com
Tue Oct 14 20:51:44 CEST 2008


> so as far as I know I have to convert this jpg to eps for using it
> inside a pstricks-picture together with includegraphics.
> so, first question: is this right? or is there a way to use jpg
> directly (together with latex->dvips->ps2pdf)?

As far as I know, pdfLaTeX has the capability to display JPG images
directly (that is, convert it to PDF and display during compile time).
LaTeX does not, and you should therefore convert images from non-EPS
(or non-PS) to EPS (or PS) before using it...

> now here is one thing I stumbled upon: by converting some jpg to eps,
> the files become quite large, e.g. the jpg has 120 KB, whereas the eps
> has 1,8 MB. I convert on a mac with the convert command inside
> terminal (imagemagic).
> so, next question: is this normal, I mean that eps files are so much
> larger than jpg files and if so, what is the reason?

Well, the answer to this is obvious in my opinion. On the one end, JPG
(and other rasterized image formats) are essentially pixelated.
Alternatively, these image format sometimes distinguish between lossy
and lossless formats. In contrast to this, images generated by
PStricks through LaTeX images are typically comprised of shapes and
objects that are essentially vectors. Hence it sometimes being
referred to as vector graphics. In that sense, you could have 500
pixels making up a straight line in a BMP/JPG which takes up (for
example) 500 bytes. However, in a vectorised image format (like EPS),
this group of 500 pixels is represented by a straight line with a
start and endpoint, and therefore would only take up (say) 4 bytes.
Conversely, a single pixel BMP/JPG might take up 1 byte of space,
while a single pixel EPS could store information on the point
location, size and shape, and therefore take up 10 bytes (say).

Back to your question... the JPG you're converting probably has a lot
of detail in it (and by detail it might be a colourful pictures with a
large number of colour jumps - from one colour to another - or it
could just plainly be that there is a lot detail!). The conversion
from JPG to EPS tries then to make vectors out of all the JPG
components (pixels), of which there is no clear relationship from the
one pixel to the next...causing the EPS to make single shapes for each
pixel in the JPG.

In short, high detail JPGs usually convert to large EPS image sizes.
Lower quality JPGs convert to smaller sized EPS files. If the images
you're trying to convert contain only straight lines and polygons, you
might consider using a tracing program rather that the
straight-forward convert from ImageMagic. Trace programs like potrace
and associated GUIs can be found online.


More information about the PSTricks mailing list