[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dvipng] does dvipng include the dpi information in its output?

From: Jan-Åke Larsson
Subject: Re: [Dvipng] does dvipng include the dpi information in its output?
Date: Mon, 15 Oct 2012 12:59:49 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121010 Thunderbird/16.0.1

jfbu skrev 10/15/2012 08:56 AM:
> Thanks for your reply: the png images I produced were for
> inclusion in a web page and as far as I could determine firefox
> displays the png images with the correspondence 1 image pixel
> equals 1 screen pixel, thus does not take into account the
> (possible) information of the real dpi used in the image. 
> Hence it is the number of pixels in the image which decides 
> of its size on screen.

You *have* read the documentation that comes with dvipng, no? It reads:

‘-D num’

    Set the output resolution, both horizontal and vertical, to num dpi
(dots per inch).
    One may want to adjust this to fit a certain text font size (e.g.,
on a web page), and for a text font height of font_px pixels (in
Mozilla) the correct formula is
    dpi = font_px * 72.27 / 10 [px * TeXpt/in / TeXpt]

    The last division by ten is due to the standard font height 10pt in
your document, if you use 12pt, divide by 12. Unfortunately, some
proprietary browsers have font height in pt (points), not pixels. You
have to rescale that to pixels, using the screen resolution (default is
usually 96 dpi) which means the formula is      

    font_px = font_pt * 96 / 72 [pt * px/in / (pt/in)]

    On some high-res screens, the value is instead 120 dpi. Good luck!

> By experiments I understood that to
> produce with gs some images (from pdf) that would display in
> a coherent manner in firefox alongside the images obtained
> via dvipng, I add to use gs -r96, or equivalent, to get 96dpi.
> If I use another dpi the size in firefox changes accordingly.
> I went through a confusing stage because Preview.app confirmed
> that the gs produced images were at 96dpi, but kept telling
> me that the older dvipng images had been at 72dpi. In fact these images
> were also at 96dpi but that information is either not in the file
> or not understood by Preview. 

Not in the file. From what I can gather (use the source, Luke!) the
currently alpha version 2.1.0 of libgd will support this. I will make
sure that dvipng uses this too, if I only can figure out how to enable
it. libgd.org is currently down, so I don't have easily accessible docs
just now (on my lunch hour).

> gs has a useful option -dDownScaleFactor so that for example
> gs -r480 -dDownScaleFactor=5 
> produces images at 96dpi that are internally treated at 480dpi
> hence the final result is far better than with gs -r96.
> (I am talking about images containing only text and math formulas)
> The quality and the number of kilobytes 
> is then about comparable to the quality and size of the dvipng
> produced images, in my experiments, (I did not try to see if 4 or 6
> were better than 5)

I'd expect that. But not quite as good, and not nearly as fast. :)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]