Discussion:
Quality of pictures/graphics using graphicx package
(too old to reply)
Gary
2006-08-20 08:37:03 UTC
Permalink
Hi all,

I have a query in relation to the quality of original/resized pictures
in LaTeX.

I am using the graphicx package and have several graphs (all of which
are saved in png format) in my LaTeX document. Additionally, I am using
pdfTeX.

I use the following commands to include my graphics:

\usepackage{graphicx}

etc..

\begin{figure} \centering
\includegraphics{filename without extension}
\caption{Some caption here.}\label{some label here}
\end{figure}

However, the graphics appearing in the pdf are of relative poor quality
in comparison to the originals; i.e. they appear "blurred" somewhat
even though I have not resized them. I have tried several extensions
(eg, jpeg), all of which produce identical results in terms of quality.
The originals are of excellent quality, so there is no reason why it
shouldn't be the same in the pdf file.

Can someone provide an explanation as to why this is so, or any
improvements in the quality of the graphics?

Thanks
Gary
Florian Müller
2006-08-20 09:38:27 UTC
Permalink
One important point about raster graphics like JPG and PNG is to use an
appropriate high resolution. For printing media the resolution should
be at least 300 DPI. Just for comparison: Normal graphics that you use
e.g. as pics for websites have a resolution of 72 DPI.
Robin Fairbairns
2006-08-20 09:50:56 UTC
Permalink
Post by Florian Müller
One important point about raster graphics like JPG and PNG is to use an
appropriate high resolution. For printing media the resolution should
be at least 300 DPI. Just for comparison: Normal graphics that you use
e.g. as pics for websites have a resolution of 72 DPI.
the other important issue is resampling.

if you're changing the size of a bitmap image, far better to do it in
a specialist application whose results you can tweak, than in a pdf
viewer over which you've really rarther little control.
--
Robin Fairbairns, Cambridge
Gary
2006-08-20 10:32:39 UTC
Permalink
The original graphic files are of excellent quality. However, once
they're included in the pdf document via the graphicx package, the
quality is quite poor. There is nothing wrong the original png/jpeg
file.

I think I have found a way around this, however. After reading up some
past threads, the solution, for me at least, is to save the graphics
file to *.eps and then convert the eps file into pdf using epstopdf.
The quality of the included graphic in the pdf file is of very similar
quality to the original. It may very well be the closest one can get.
Heiko Oberdiek
2006-08-20 11:53:59 UTC
Permalink
Post by Gary
The original graphic files are of excellent quality. However, once
they're included in the pdf document via the graphicx package, the
quality is quite poor. There is nothing wrong the original png/jpeg
file.
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
Post by Gary
I think I have found a way around this, however. After reading up some
past threads, the solution, for me at least, is to save the graphics
file to *.eps and then convert the eps file into pdf using epstopdf.
The quality of the included graphic in the pdf file is of very similar
quality to the original. It may very well be the closest one can get.
It look that you are not too precise about the nature of the
graphics and the comparison.

Yours sincerely
Heiko <***@uni-freiburg.de>
Gary
2006-08-20 12:40:06 UTC
Permalink
Post by Heiko Oberdiek
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
If that is so, then how could one explain the discrepancy in quality
between the original png file and the pdf document with the graphic?
Robin Fairbairns
2006-08-20 13:22:50 UTC
Permalink
Post by Gary
Post by Heiko Oberdiek
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
If that is so, then how could one explain the discrepancy in quality
between the original png file and the pdf document with the graphic?
quite impossible, since you've not shown us the \includegraphics
commands. (or even responded to my comment about resampling.)
--
Robin Fairbairns, Cambridge
Gary
2006-08-20 21:28:47 UTC
Permalink
Post by Robin Fairbairns
Post by Gary
Post by Heiko Oberdiek
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
If that is so, then how could one explain the discrepancy in quality
between the original png file and the pdf document with the graphic?
quite impossible, since you've not shown us the \includegraphics
commands. (or even responded to my comment about resampling.)
The \includegraphics commands are in my first post.

The images have not been resampled.
Dan Luecking
2006-08-21 18:28:20 UTC
Permalink
Post by Gary
Post by Robin Fairbairns
Post by Gary
Post by Heiko Oberdiek
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
If that is so, then how could one explain the discrepancy in quality
between the original png file and the pdf document with the graphic?
quite impossible, since you've not shown us the \includegraphics
commands. (or even responded to my comment about resampling.)
The \includegraphics commands are in my first post.
The images have not been resampled.
The viewing program resamples them to the screen resolution for
display on screen.
The printing ptogram resamples them to the printer's resolution
for printing them on paper.

You could try viewing the pdf at high magnification to see if
any detail is lost upon inclusion.

The fact that eps -> pdf conversion improves the quality suggests that
jpeg and png were inappropriate graphic formats. If you created these
with a vector drawing program (as opposed to a bitmap oriented paint
program), saving them as eps or pdf is nearly always best. Also jpeg
is nearly always inappropriate except for photos.


Dan
To reply by email, change LookInSig to luecking
--
Posted via a free Usenet account from http://www.teranews.com
allythemartian
2006-08-21 20:12:19 UTC
Permalink
Two kinds of graphics formats exist (that's exactly two, count 'em):
vector and raster.

Very loosely, vector includes .dvi .ps .eps .pdf .xls .doc .wmf .emf
.vsd and so on
Raster includes .jpg .bmp .png .tif .tiff .gif

my rule for including graphics is this: always keep vector graphics as
vector graphics. This always preserves the whole of the quality.
Anything that doesn't start life as a jpeg (e.g. from a digital camera)
probably starts life as vector graphics. Graphs, for example, always
start in vector form. If you turn vector graphics into raster, you
WILL lose quality every time. It's a one way transformation as well,
like turning a pig into a sausage.

So to preserve vector quality while also letting latex include them
properly, I always turn the graphics into .pdf files.

To do this I use CutePDF writer (a free download from www.cnet.com) to
print the graph page (or whatever I want) from say a spreadsheet into a
pdf file, and then say \includegraphics{mygraph.pdf}

This works with pdflatex. I don't use the dvi or ps writers; with
them you might to better creating .eps files (though these have their
own problems - the old BoundingBox chestnut).

When working with Visio, CutePDF writer is tricky: you have to faff
around for ages getting custom paper size defined to match the drawing
or you get too much white space around it. But that's a minor point;
otherwise it works a treat.

Of course, vector graphics files can include raster graphics, in which
case the vector rule still wins in my view.
Gary
2006-08-21 23:16:41 UTC
Permalink
Thanks for the all the replies. They've all been very helpful. Saving
the graphic into eps and then converting them to pdf via epstopdf is
the way to go with minimal quality loss.

Heiko Oberdiek
2006-08-20 13:42:51 UTC
Permalink
Post by Gary
Post by Heiko Oberdiek
pdfTeX doesn't alter the quality. The JPEG data are only copied.
Depending on the pdfTeX version this is done with PNG as well
or the PNG data are uncompressed and recompressed
without altering the image data.
If that is so, then how could one explain the discrepancy in quality
between the original png file and the pdf document with the graphic?
Extact the image with pdfimages and compare the image data with
the original.

The difference is probably between the viewers (and some viewers
can be configured: antialiasing, ...).

Yours sincerely
Heiko <***@uni-freiburg.de>
Gary
2006-08-20 21:32:15 UTC
Permalink
Post by Heiko Oberdiek
Extact the image with pdfimages and compare the image data with
the original.
The difference is probably between the viewers (and some viewers
can be configured: antialiasing, ...).
No, the difference is not with the viewers. The printed version of the
graphics is somewhat blurred as well. I get pretty much what I see on
the screen.
Heiko Oberdiek
2006-08-20 22:35:59 UTC
Permalink
Post by Gary
Extract the image with pdfimages and compare the image data with
the original.
The difference is probably between the viewers (and some viewers
can be configured: antialiasing, ...).
No, the difference is not with the viewers. The printed version of the
graphics is somewhat blurred as well. I get pretty much what I see on
the screen.
How do you know? You are using the same program for all
viewing/printing different formats?

You don't say anything about used programs, versions, settings, ...
Also you could put somewhere examples and post the urls here.

Yours sincerely
Heiko <***@uni-freiburg.de>
tlhiv
2006-08-21 06:58:15 UTC
Permalink
Gary,

Try converting your PNG/JPEG to PDF (if using PDF(La)TeX) or to EPS (if
using (La)TeX) using sam2p. If you don't have this program, you can
get it from

http://www.inf.bme.hu/~pts/sam2p/

or alternatively you can convert it from my website at

http://www.tlhiv.org/rast2vec/

This program (sam2p) does an outstanding job at just simply placing a
EPS/PDF wrapper around your raster image. I think you'll find that if
you use \includegraphics on this converted graphic then your quality
should be just fine.

As an alternative to the above proposed "solution", you may try placing

\pdfcompresslevel 0

in your preamble. I haven't tested this though, so I can't provide an
educated guess of whether it will help.

--
Troy Henderson
Assistant Professor
Department of Mathematical Sciences
United States Military Academy
http://www.tlhiv.org
Loading...