Recent versions of imagemagick write resolution in jpeg

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Recent versions of imagemagick write resolution in jpeg

Post by broucaries »

he current version of imagemagick (and its library used by gkrellshoot)
creates jpeg images that cannot be used in pdflatex with graphicx
anymore.

There is already a bugreport in redhats bugzilla[0].

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1086715

To have the informations also in this bug, this is the result I have
seen (Only relevant part):
- --- input.tex
...
\usepackage{graphicx}
...
\includegraphics{gkrellShoot_xxxx}
...
- ---

- --- Output
...
pdfTeX warning: pdflatex: arithmetic: number too big


pdfTeX warning: pdflatex: arithmetic: number too big
<gkrellShoot_xxxx.jpg, id=165, --32768.0pt x 0.0pt>
<use gkrellShoot_xxxx.jpg>
Overfull \hbox (67.0553pt too wide) has occurred while \output is active
[][] \T1/cmss/m/sc/6 ([])

Analysis:
The reason is very simple: recent versions of imagemagick write
resolution information to the JPEG files (such as 1 dpi), so
you end up with very very large image (several meters large !), and
latex just gives up.

While I agree this is clearly a problem with imagemagick, it is also
a bug in LaTeX.

A simple workaround is the following: add a -density 75 option
before the output in convert:

convert bad_jpeg.jpeg -density 75 latex_friendly_jpeg.jpeg

I do not know if it is a bug or a feature....
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Recent versions of imagemagick write resolution in jpeg

Post by magick »

Not a bug. If you don't specify a resolution with the -density option the JPEG library sets defaults as follows:
  • UINT8 density_unit
    UINT16 X_density
    UINT16 Y_density
    The resolution information to be written into the JFIF marker;
    not used otherwise. density_unit may be 0 for unknown,
    1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1
    indicating square pixels of unknown size.
suggests the bug is in pdflatex for not properly handling the JPEG default density. We could set a default resolution to 72,72 for JPEG but that would mean that pdflatex would work for ImageMagick but fail for other applications that use the JPEG defaults when writing a JPEG image. What is your recommendation?
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: Recent versions of imagemagick write resolution in jpeg

Post by broucaries »

My sugestion is ignore and document this behavior and workarroud with old pdflatex version (will try to fix newer)
Post Reply