[luatex] handling resolution of jpg files

luigi scarso luigi.scarso at gmail.com
Mon Jan 23 10:24:58 CET 2017


On Sat, Jan 14, 2017 at 12:03 AM, David Carlisle <d.p.carlisle at gmail.com> wrote:
> Luigi,
>
>> 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.
>
> I think that's an unfortunate choice and ask you to at least give a
> customisation
> option to take the other choice.

> https://github.com/latex3/graphics-def/blob/master/testfiles/clip-1-2.jpg
> https://github.com/latex3/graphics-def/blob/master/testfiles/clip-1-2.png
thank you for the png --- this shows that I could  use the  Exif
0x5110 , Exif 0x5111  and Exif 0x5112
to set the resolution of the jpeg.
Exif 0x5110                     : 1
Exif 0x5111                     : 4724
Exif 0x5112                     : 4724
means 4724pixel/1m = 119.989 pixel/in which ~120dpi
(of course Exif 0x5110 (ie PixelUnit)  can be different from Exif
ResolutionUnit , so we have the same problem).

The png is correct simply because there is a single field for the  x
resolution (and one for the y resolution)
so no ambiguity.
But there is no a standard way to convert jpeg exif tags into  png chunks.

I have just commited a new writejpg.w, with some changes:
if there is an Exif header with a standard xres, yres and a valid unit
(which can be omitted and it's taken as inch)
then it wins over the input resolution.
We support now also the Exif 0x5110, 0x5111, 0x5112 (used by MicroSoft
?) but only if the unit is correct.
A warning is emitted if the input resolution is different from the
Exif resolution , or if xres=1 or yres=1,
or if the Exif resolutions looks bad.
In short: we use the Exif resolution if it's  valid .


-- 
luigi


More information about the luatex mailing list