[luatex] handling resolution of jpg files

luigi scarso luigi.scarso at gmail.com
Fri Jan 13 19:01:19 CET 2017


On Fri, Jan 13, 2017 at 12:23 PM, David Carlisle <d.p.carlisle at gmail.com> wrote:
>  Further to my last mail, I just tried the same test file with
> latex+dvipdfmx and it works like pdftex (the clipping  is tight to the
> numbered circles)  but I get the warning
>
>
> extractbb:warning: JPEG: Inconsistent resolution may have specified in
> Exif and JFIF: 72x72 - 120x120
>
> So arguably it's a fault in the image file, (and not your fault:-)
> although given that it's easy to produce such things and hard to spot
> in advance, it would perhaps be good if things could go the same way
> or error or at least warn...
>
> In this case I just drew a couple of circles in an empty  microsoft
> paint and clicked save as jpeg, so it's not as if the inconsistent
> data occurred due to some complicated pipeline of image
> transformations.
>
>
> David

It should  be fixed now in experimental,
but in any case it's different from pdftex.
If  there is an EXIF tag then we set the resolution from there
assuming a default  of 72 pixel per inch,
and this take the precedence over the JFIF data.
Otherwise we take the JFIF data.
In case of clip-1-2.jpg there is at least one EXIF tag, so we start
with the default resolution  of 72dpi
and we keep it, because there is no tags about resolution :
$ exiftool -a -u clip-1-2.jpg
ExifTool Version Number         : 10.10
File Name                       : clip-1-2.jpg
Directory                       : .
File Size                       : 12 kB
File Modification Date/Time     : 2017:01:12 14:58:28+01:00
File Access Date/Time           : 2017:01:12 14:58:28+01:00
File Inode Change Date/Time     : 2017:01:12 14:58:49+01:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 120
Y Resolution                    : 120
Exif Byte Order                 : Big-endian (Motorola, MM)
Exif 0x0301                     : 2.199978
Exif 0x0303                     : 0
Exif 0x5110                     : 1
Exif 0x5111                     : 4724
Exif 0x5112                     : 4724
Image Width                     : 243
Image Height                    : 214
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 243x214
Megapixels                      : 0.052


From
https://msdn.microsoft.com/en-us/library/ms932271.aspx
PropertyTagPixelPerUnitX
Pixels per unit in the x direction.
Tag 0x5111
Type PropertyTagTypeLong
Count 1

PropertyTagPixelPerUnitY
Pixels per unit in the y direction.
Tag 0x5112
Type PropertyTagTypeLong
Count 1

PropertyTagPixelUnit
Unit for PropertyTagPixelPerUnitX and PropertyTagPixelPerUnitY.
A setting of 0 indicates that property is unknown.
Tag 0x5110
Type PropertyTagTypeByte
Count 1

but these tags does not affect the resolution.

So in luatex we have a width of 243pixels at 72dpi, hence 243.91125pt.

On the other side pdftex takes the other way, so we have 243pixels at
120dpi, hence  146.34676pt.


-- 
luigi


More information about the luatex mailing list