[pdftex] graphic{s,x} PNG + pdflatex bug

Thanh Han The thanh at river-valley.org
Fri May 7 14:58:34 CEST 2010


On 5/7/10, Jim Diamond <Jim.Diamond at acadiau.ca> wrote:
> On Fri, May  7, 2010 at 13:25 (+0100), Thanh Han The wrote:
>
>  > On 5/7/10, Jim Diamond <Jim.Diamond at acadiau.ca> wrote:
>  >> On Fri, May  7, 2010 at 08:19 (-0300), George N. White III wrote:
>
>  >>> On Thu, May 6, 2010 at 3:55 PM, Jim Diamond <Jim.Diamond at acadiau.ca> wrote:
>
>  >>>> On Thu, May  6, 2010 at 15:36 (-0300), George N. White III wrote:
>
>  >>>>> On Thu, May 6, 2010 at 2:33 PM, Taco Hoekwater <taco at elvenkind.com> wrote:
>  >>>>>> Nico Schlömer wrote:
>
>  >>>>>>> Hi all,
>
>  >>>>>>> I experienced a weird bug using \includegraphics of the graphicx
>  >>>>>>> package with pdflatex 1.40.10.
>
>  >>>>>>> I try to load the attached PNG file, and unlike with other PNG files,
>  >>>>>>> pdflatex would just bail out with
>
>  >>>>>>> ==================== *snip* ====================
>  >>>>>>> [...]
>  >>>>>>> [Loading MPS to PDF converter (version 2006.09.02).]
>  >>>>>>> )
>  >>>>>>> ! Dimension too large.
>  >>>>>>> <argument> \wd \@tempboxa
>  >>>>>>> l.7 \includegraphics{img1.png}
>  >>>>>>> ?
>  >>>>>>> ==================== *snap* ====================
>
>  >>>>>>> David Carlisle, maintainer of graphicx, suggests that may be a bug in
>  >>>>>>> pdflatex -- What do you reckon?
>
>  >>>>>> Well, this png specifies a resolution of 0.9906 pixel per inch so it
>  >>>>>> has natural sizes of about 252 inch (6.4m). So in my opinion something
>  >>>>>> *is* wrong with the png.
>
>  >>>>>> Best wishes,
>  >>>>>> Taco
>
>  >>>>> $ identify -verbose img1.png |head
>  >>>>> Image: img1.png
>  >>>>> Format: PNG (Portable Network Graphics)
>  >>>>> Class: DirectClass
>  >>>>> Geometry: 250x250+0+0
>  >>>>> Resolution: 0.39x0.39
>  >>>>> Print size: 641.026x641.026
>  >>>>> Units: PixelsPerCentimeter
>
>  >>>>> I loaded the PNG in Adobe Photoshop and saved it as  img2.png:
>
>  >>>>> $ identify -verbose img2.png |head
>  >>>>> Image: img2.png
>  >>>>> Format: PNG (Portable Network Graphics)
>  >>>>> Class: DirectClass
>  >>>>> Geometry: 250x250+0+0
>  >>>>> Resolution: 0.39x0.39
>  >>>>> Print size: 641.026x641.026
>  >>>>> Units: PixelsPerCentimeter
>
>  >>>>> $ pngcheck -vt img1.png
>  >>>>> File: img1.png (92868 bytes)
>  >>>>> chunk IHDR at offset 0x0000c, length 13
>  >>>>>     250 x 250 image, 32-bit RGB+alpha, non-interlaced
>  >>>>> chunk sBIT at offset 0x00025, length 4
>  >>>>> red = 8 = 0x08, green = 8 = 0x08, blue = 8 = 0x08, alpha = 8 = 0x08
>  >>>>> chunk pHYs at offset 0x00035, length 9: 39x39 pixels/meter (1 dpi)
>  >>>>> chunk IDAT at offset 0x0004a, length 8192
>  >>>>> zlib: deflated, 32K window, default compression
>  >>>>> chunk IDAT at offset 0x02056, length 8192
>  >>>>> chunk IDAT at offset 0x04062, length 8192
>  >>>>> chunk IDAT at offset 0x0606e, length 8192
>  >>>>> chunk IDAT at offset 0x0807a, length 8192
>  >>>>> chunk IDAT at offset 0x0a086, length 8192
>  >>>>> chunk IDAT at offset 0x0c092, length 8192
>  >>>>> chunk IDAT at offset 0x0e09e, length 8192
>  >>>>> chunk IDAT at offset 0x100aa, length 8192
>  >>>>> chunk IDAT at offset 0x120b6, length 8192
>  >>>>> chunk IDAT at offset 0x140c2, length 8192
>  >>>>> chunk IDAT at offset 0x160ce, length 2530
>  >>>>> chunk IEND at offset 0x16abc, length 0
>  >>>>> No errors detected in img1.png (16 chunks, 62.9% compression).
>  >>>>> $ pngcheck -vt img2.png
>  >>>>> File: img2.png (92076 bytes)
>  >>>>> chunk IHDR at offset 0x0000c, length 13
>  >>>>>     250 x 250 image, 32-bit RGB+alpha, non-interlaced
>  >>>>> chunk bKGD at offset 0x00025, length 6
>  >>>>> red = 0x00ff, green = 0x00ff, blue = 0x00ff
>  >>>>> chunk pHYs at offset 0x00037, length 9: 39x39 pixels/meter (1 dpi)
>  >>>>> chunk vpAg at offset 0x0004c, length 9
>  >>>>> unknown private, ancillary, safe-to-copy chunk
>  >>>>> chunk IDAT at offset 0x00061, length 32768
>  >>>>> zlib: deflated, 32K window, maximum compression
>  >>>>> chunk IDAT at offset 0x0806d, length 32768
>  >>>>> chunk IDAT at offset 0x10079, length 26301
>  >>>>> chunk tEXt at offset 0x16742, length 37, keyword: create-date
>  >>>>>     2010-05-06T12:39:23-03:00
>  >>>>> chunk tEXt at offset 0x16773, length 37, keyword: modify-date
>  >>>>>     2010-05-06T12:35:33-03:00
>  >>>>> chunk IEND at offset 0x167a4, length 0
>  >>>>> No errors detected in img2.png (10 chunks, 63.2% compression).
>
>  >>>>> Both versions look the same using Imagemagick's display,
>  >>>>> but img2.png does not give the error, so image size does
>  >>>>> not explain the error.
>
>  >>>> Did you compare the rest of the output of "identify -verbose" ?  There
>  >>>> may be something illuminating there.  As your pngcheck output shows,
>  >>>> the photoshop version is quite a bit different.
>
>  >>> I did, but it doesn't seem helpful:
>
>  >>> $ diff img1.ident img2.ident
>  >>> 1c1
>  >>> < Image: img1.png
>  >>> ---
>  >>>> Image: img2.png
>  >>> 310c310
>  >>> <   Background color: white
>  >>> ---
>  >>>> Background color: rgba(0,0,0,1)
>  >>> 321,322c321,324
>  >>> <     date:create: 2010-05-06T12:39:23-03:00
>  >>> <     date:modify: 2010-05-06T12:35:33-03:00
>  >>> ---
>  >>>> create-date: 2010-05-06T12:39:23-03:00
>  >>>> date:create: 2010-05-06T12:50:09-03:00
>  >>>> date:modify: 2010-05-06T12:50:09-03:00
>  >>>> modify-date: 2010-05-06T12:35:33-03:00
>  >>> 327c329
>  >>> <   Filesize: 92.9KB
>  >>> ---
>  >>>> Filesize: 92.1KB
>
>  >> Curious.
>
>  >> I used "display" and "xv" to create "copies" of the file, and the "xv"
>  >> one makes pdflatex happy, but the "display" one makes pdflatex crash
>  >> and burn.
>
>  >> xv does change the resolution to 72x72 with "undefined" units, but as
>  >> George points out, that (by itself anyway) doesn't appear to be te
>  >> issue.
>
>  >> Maybe some pdftex internals person/people will need to chime in,
>  >> should they feel so inclined.
>
>  > Taco is one core member of the pdftex team, and explained it
>  > all. I don't know what more could be said about this.
>  > Anyway, here my attempt:
>
>  > when a bitmapped image is included, pdftex tries to figure
>  > out the dimension of the image in the output (let's call
>  > it the "intended dimension"):
>
>  >   (1) if specified explicitly by the user (eg via the keyword
>  >       "width" or "height"), then use it
>
>  >   (2) if not specified explicitly, and the image contains
>  > resolution, then use it
>
>  >   (3) otherwise, use the resolution specified by
>  >       \pdfimageresolution to calculate the intended dimension.
>
>  > [btw, all of this is in the pdftex manual.]
>
>  > now let's look at our case:
>  > ,--------,
>  >> \includegraphics{img1.png}
>  > `--------`
>
>  > no explicit dimension, but resolution available => step (2)
>  > taken. Then it turned out that the intended dimension
>  > (252inch) is too big for (pdf)tex. So the cause of the
>  > problem (for pdftex) is too big (intended) dimension of the
>  > image.
>
>  Thanh,
>
>  thanks for the explanation, but...
>
>  George's text above claims that the size is not (by itself) the issue:
>
>  >>>>> Both versions look the same using Imagemagick's display,
>  >>>>> but img2.png does not give the error, so image size does
>  >>>>> not explain the error.
>
>  I would have been happy to accept Taco's comments until reading that.
>  Would you not agree that Taco's explanation and George's experiment
>  are contradictory?

let's look at this test:
,--------,
| \documentclass{minimal}
| \usepackage{graphicx}
| \begin{document}
| \hbox{}
|
| %% error: dimension too large
| \includegraphics{img1.png}
|
| %% error: dimension too large.
| \includegraphics[width=1in]{img1.png}
|
| %% no output (too big page discarded)
| \pdfximage {img1.png}
| \pdfrefximage\pdflastximage
|
| %% size specified, ok
| \pdfximage width 1in {img1.png}
| \pdfrefximage\pdflastximage
|
|
| \end{document}
`--------`

I hope this makes clear that size (or resolution) is the
cause of the problem. It's also worthwhile to note that
graphicx does some calculation with intended dimension, and
hence specifying the dimension for \includegraphics didn't
help.


Regards,
Thanh



More information about the pdftex mailing list