[XeTeX] strange case of overlapping graphics

Heiko Oberdiek heiko.oberdiek at googlemail.com
Thu Jun 10 19:35:20 CEST 2021


Hello,

the properties of the PNG file "Zaborowski_MBC_page19y42_a.png"
are (retrieved by display from ImageMagicks):

   png:IHDR.width=112 pixels
   png:IHDR.height=42 pixels
   png:pHYs.x_res=984 pixels/m ≈ 25 dpi
   png:pHYs.y_res=276 pixels/m ≈  7 dpi

The image has different resolutions in the x- and y-directions.
The final image size is:
   width  ≈ 113.8 mm ≈ 4.48 in
   height ≈ 152.2 mm ≈ 5.99 in

The TeX compilers pdfTeX and LuaTeX correctly handle the image size.
However, there is a bug in the XeTeX pipeline, the dimensions are 
correctly calculated (extractbb), but the image is embedded with
the same resolution in both directions.

I assume that the image looks distorted with pdfTeX. That means
the different resolutions in the pHYs PNG chunk is wrong.
You can fix this in Gimp --> Menu --> Image --> Scale Image:
Set the same physical resolution value to both the "X resolution"
and the "Y resolution". Some math:

   3ex = 12.91663 pt = 42 pixels / resolution

   resolution = (42 pixels / 12.91663 pt)   ≈ 3.25 pixels / pt
              * (72.27 pt / 1 in)           ≈ 235 pixels / in   [= dpi]
              * (1 in / 25.4 mm)            ≈ 9.2518 pixels / mm

Do *NOT* change the width or height. This would cause scaling
the image data with the quality settings.
   If only the resolution settings are changed, the image data
are kept intact when the "Scale" button is pressed.
Then the scaling operation only changes the resolution values
for the images that are used, when the image is exported.

Export the image as PNG with "Save resolution" enabled.

Then, the new image can be used with pdfTeX, LuaTeX, and XeTeX.
Since the x- and y-resolutions are the same, the bug of XeTeX
is avoided.

Yours sincerely
   Heiko


More information about the XeTeX mailing list.