Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Slow PNG inclusion with pdfLaTeX

1,197 views
Skip to first unread message

remol...@hotmail.com

unread,
Feb 26, 2005, 11:07:14 AM2/26/05
to
Hi,

I need to put a lot of PNG pictures in a tex document. But including
PNGs makes pdfLaTeX to hang a few seconds after including each PNG.
This doen't happens with other file types as JPG, PDF, etc.

Is there a way to ommit this delay? Without converting all PNGs to
other format?

Thanks very much.

Daniel.

Morten Høgholm

unread,
Feb 26, 2005, 11:15:32 AM2/26/05
to
On 26 Feb 2005 08:07:14 -0800, <remol...@hotmail.com> wrote:

> Hi,
>
> I need to put a lot of PNG pictures in a tex document. But including
> PNGs makes pdfLaTeX to hang a few seconds after including each PNG.
> This doen't happens with other file types as JPG, PDF, etc.

This should not happen. Can you give us some information on your version
of pdftex? I have
This is pdfeTeX, Version 3.141592-1.21a-2.2 (MiKTeX 2.4)
--
Morten Høgholm
My armpits may be smelly but my is address not.
UK-TUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>

remol...@hotmail.com

unread,
Feb 26, 2005, 11:28:29 AM2/26/05
to
Thanks Morten,

The version:

This is pdfeTeX, Version 3.141592-1.20a-2.2 (Web2C 7.5.3)

I'm using Gerben Wierda's i-Packages for MacOS X

Daniel.

Morten Høgholm

unread,
Feb 26, 2005, 11:54:06 AM2/26/05
to

From v1.20b pdftex includes libpng so it's quite likely this is the same
problem. Try asking for an upgrade (if there isn't one available already).

Taco Hoekwater

unread,
Feb 26, 2005, 12:22:17 PM2/26/05
to

Hi,

Including PNG images in pdftex is quite slow compared
to the other file formats because it actually has to
decompress (and recompress) the image data.

Assuming you have netpbm and (info)zip installed,
you can check if the problem is pdftex-only by
clocking the speed of a command like this:

$ pngtoppm <pngimage> | zip tester -

(or any other kind of image conversion that does not have
to work too hard on the output file format)

If such a command is also slow, then there is nothing
specifically wrong with pdftex. In that case, converting
all of the images to jpeg is probably your best option.

Hope this helps,

Taco

Kirk Job-Sluder

unread,
Feb 26, 2005, 2:48:03 PM2/26/05
to
On 2005-02-26, Taco Hoekwater <ta...@aanhet.net> wrote:
>
> If such a command is also slow, then there is nothing
> specifically wrong with pdftex. In that case, converting
> all of the images to jpeg is probably your best option.

Hrm. Just thinking about this a little bit (because I've also had
problems with the mentioned conversions.) Does anybody have suggestions
for jpg settings that work well with pdflatex? I've been using png
primarily because the source is bitmap graphics of screenshots, but if
the pdf construction process involves conversion from png to jpg
compression anyway, I might as well do the conversion myself.


>
> Hope this helps,
>
> Taco
>
> remol...@hotmail.com wrote:

--
Kirk Job-Sluder
"The square-jawed homunculi of Tommy Hilfinger ads make every day an
existential holocaust." --Scary Go Round

Tristan Miller

unread,
Feb 26, 2005, 3:12:31 PM2/26/05
to
Greetings.

In article <1109434034....@l41g2000cwc.googlegroups.com>,

Use the [draft] option to your \documentclass when compiling preliminary
versions of your document. This way the graphics won't actually get
included; they'll just be placeholder boxes.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you

Harald Hanche-Olsen

unread,
Feb 26, 2005, 6:27:31 PM2/26/05
to
+ Kirk Job-Sluder <ki...@eyegor.jobsluder.net>:

| I've been using png primarily because the source is bitmap graphics
| of screenshots, but if the pdf construction process involves
| conversion from png to jpg compression anyway, I might as well do
| the conversion myself.

It doesn't. PDF supports many forms of image compression. JPEG is
one of them (called DCT, for discrete cosine transform), and JPEG
images are AFAIK imported mostly by copying all the bits. It's
possible that PNG images are stored in a format not immediately usable
in PDF the same way, in which case the image needs to be decoded and
then reencoded. That will take time, of course.

If this is really annoying, perhaps because you're doing many TeX runs
while ironing out the layout, you could try the draft option. Or you
could convert all the images to PDF and include the resulting images
instead. I don't know if this will be faster - I haven't tried it.

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow

remol...@hotmail.com

unread,
Feb 26, 2005, 11:06:50 PM2/26/05
to
Thanks for all the discussion!

I have choosed PNG because is a lossless format, and very very small
files. The same picture as JPG are 350KB, as TIF ~120KB and as and as
PNG mere 60KB.
Of course i use \draft mode when i can, but in the final testing i need
to see the pictures.

Now i have learned that PDF only accept JPEG pictures and RAW pictures,
is this right?
So, if this the case, why importing the same picture as TIFF(a
compressed image type) instead of PNG don't make a delay? Is the TIFF
compression algorithm the same as PDF?

Thanks very much to all of you,

Daniel.

Tristan Miller

unread,
Feb 26, 2005, 11:33:01 PM2/26/05
to
Greetings.

In article <1109477210.6...@l41g2000cwc.googlegroups.com>,

TIFF images may or may not be compressed; it depends how it was saved. The
most common method of compression in TIFF is LZW, but a lot of programs
still save them uncompressed.

Hartmut Henkel

unread,
Feb 27, 2005, 4:34:28 AM2/27/05
to
<remol...@hotmail.com> wrote:

If you compile from source, maybe check

http://www.circuitwizard.de/pdftex/patch5

which should read much faster, if the PNG files are of the right type. The
problem with this rough patch is that it's now getting obsolete as it
doesn't (yet) support new transparency features to come.

Regards, Hartmut
--
H. Henkel, Oftersheim

Harald Hanche-Olsen

unread,
Feb 27, 2005, 5:21:17 AM2/27/05
to
+ remol...@hotmail.com:

| Now i have learned that PDF only accept JPEG pictures and RAW pictures,
| is this right?

I don't know what you mean by RAW. The latest pdftex accepts PNG,
JPEG and PDF.

| So, if this the case, why importing the same picture as TIFF(a
| compressed image type) instead of PNG don't make a delay?

You have an old version of pdftex if it can import TIFF.

| Is the TIFF compression algorithm the same as PDF?

As someone already pointed out, TIFF supports many compression
algorithms, including no compression. PDF supports several too: LZW,
Flate, RunLength, CCITTFax, JBIG2 (since pdf 1.4), DCT (aka JPEG), JPX
(since 1.5; aka JPEG 2000). Source for this information: PDF
Reference 1.6, page 65. (Available online from Adobe.) PNG uses
Deflate. It is possible that Flate and Deflate are the same - they
are definitely closely related. But it is also possible that there
are subtle differences in the way data is encoded in the two formats
that images need to be decoded and then reencoded, which would explain
the delays you are seeing. In fact, doing a simpleminded comparison
between a PNG file and the PDF file resulting from including it, I
fail to find any common bits, so I think this is likely the case.

Harald Hanche-Olsen

unread,
Feb 27, 2005, 5:27:23 AM2/27/05
to
+ remol...@hotmail.com:

| Now i have learned that PDF only accept JPEG pictures and RAW pictures,
| is this right?

I don't know what you mean by RAW. The latest pdftex accepts PNG,
JPEG and PDF.

| So, if this the case, why importing the same picture as TIFF(a


| compressed image type) instead of PNG don't make a delay?

You have an old version of pdftex if it can import TIFF.
Newer versions cannot; it proved to be too much trouble.

| Is the TIFF compression algorithm the same as PDF?

As someone already pointed out, TIFF supports many compression


algorithms, including no compression. PDF supports several too: LZW,
Flate, RunLength, CCITTFax, JBIG2 (since pdf 1.4), DCT (aka JPEG), JPX
(since 1.5; aka JPEG 2000). Source for this information: PDF
Reference 1.6, page 65. (Available online from Adobe.) PNG uses
Deflate. It is possible that Flate and Deflate are the same - they
are definitely closely related.

A post in a different subthread pointed to the following URL, which
explains a lot.

http://www.circuitwizard.de/pdftex/patch5/

Heiko Oberdiek

unread,
Feb 27, 2005, 8:39:47 AM2/27/05
to
Taco Hoekwater <ta...@aanhet.net> wrote:

> Including PNG images in pdftex is quite slow compared
> to the other file formats because it actually has to
> decompress (and recompress) the image data.

For intermediate pdfTeX runs the compress level can
be reduced (larger file size, but faster speed), eg.
\pdfcompresslevel=2
Values: 0 (no compression) to 9 (max. compression)

It also can be use on command line,
example for test.tex, and use appropriate quotes:
pdf(la)tex '\pdfcompressionlevel=2 \input' test
or
pdflatex '\pdfcompresslevel=2 \input{test}'

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Heiko Oberdiek

unread,
Feb 27, 2005, 8:39:48 AM2/27/05
to
Kirk Job-Sluder <ki...@eyegor.jobsluder.net> wrote:

> On 2005-02-26, Taco Hoekwater <ta...@aanhet.net> wrote:
> >
> > If such a command is also slow, then there is nothing
> > specifically wrong with pdftex. In that case, converting
> > all of the images to jpeg is probably your best option.
>
> Hrm. Just thinking about this a little bit (because I've also had
> problems with the mentioned conversions.) Does anybody have suggestions
> for jpg settings that work well with pdflatex? I've been using png
> primarily because the source is bitmap graphics of screenshots,

Convert the PNG files to PDF and embed the PDF. Then the image
data are not decompressed and compressed. And the conversion
is lossless.

Yours sincerley
Heiko <ober...@uni-freiburg.de>

remol...@hotmail.com

unread,
Feb 27, 2005, 5:10:44 PM2/27/05
to
Thanks Heiko,

I have tried your idea of \pdfcompresslevel0 and the PNG loads very
faster now. I think i will use this, because converting PNG to PDF is
time-consuming and i have the pictures distributed in different
directories.

Thanks to all of you that helped to find a soluttion.

Daniel.

steffen....@gmail.com

unread,
Oct 26, 2013, 8:58:11 AM10/26/13
to
For me the problem was caused by Sophos Antivirus Software (InterCheck). This caused pdflatex to freeze a lot while processing png figures. Without InterCheck running, it's all smooth.
0 new messages