Brion Vibber brion@pobox.com writes:
David Kastrup wrote:
Brion Vibber brion@pobox.com writes:
Well, if we can get the height in pixels of the image (easy) _and_ the Y-pixel position in the image of the baseline (????) it might be
Well, as I already wrote: the information can be retrieved by using preview.sty and/or dvipng, easily. dvipng has command line options for writing out the ascender/descender information, and preview.sty will output the interesting information if you just use the "lyx" option.
Saying it's easy is nice, providing code to do it is better. ;)
What do you mean, "to do it"?
With preview.sty, the output is written into a single line, starting with a unique keyword phrase, followed by four integers (the number of the image, relevant width, depth and height) in the units of scaled TeX points (of which there are exactly 65781.76 per Postscript point).
That _is_ the code to do it. Its output is a single identifiable line of complete trivially parseable ASCII.
Something like
Preview: Snippet 3 13200342 455360 36455
And then there is another line of completely trivially parseable ASCII (keyword and 4 numbers) that tells the size of the border.
Something like
Preview: Tightpage 32891 32891 32891 32891
If you did not change the border sizes yourself (and no LaTeX code outside of your control did), the numbers are fixed: 0.50001 PostScript points on each side. So you need not even parse that information.
Extracting these lines from the .log file or the terminal output is a matter of matching with
^Preview: Snippet ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)
and then using the \1 \2 \3 \4, with whatever matcher/processor you happen to be working with.
Really, I am at a loss at what "code" to show for that. It should be a one-liner in most scripting languages.