Question : Decipher Image Size in RTF coding (HARD ONE!!!)

When reading an RTF stream, I'm having a problem determining the size of a graphic residing in an RTF file (pick any RTF file you may already have).

SCENARIO:
I need to extract graphics from an RTF file by reading the source of that RTF. So far I've been successful, until I try to determine if a graphic was re-sized in the document view. Reading the RTF specification gives clues, but there still seems to be some critical piece of information that I'm missing.

Here's an example of what I'm seeing:

{\*\shppict{\pict{\*\picprop\shplid1025{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn pibFlags}{\sv 2}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn fLayoutInCell}{\sv 1}}}\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw9220\pich2760\picwgoal5227\pichgoal1565\pngblip\bliptag1589406005}
(...hex data for a 1089px by 326px graphic then follows...)

It's clear to me that "\picw9220\pich2760\picwgoal5227\pichgoal1565" are important items and I understand that "picwgoal" and "pichgoal" hold values in TWIPS. When I do a simple division by 20 "picwgoal5227" and "pichgoal1565" results in "261px" and "78px" the exact size as displayed in
the document view.

But here's the problem, the very next RTF file doesn't follow the same logic:

{\shp{\*\shpinst\shpleft0\shptop12\shpright1365\shpbottom1272\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr2\shpwrk0\shpfblwtxt0\shpz0\shplid4097{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn pib}{\sv{\pict\picscalex100\picscaley99\piccropl0\piccropr0\piccropt0\piccropb0\picw2404\pich2235\picwgoal1363\pichgoal1267\jpegblip\bliptag1869718168}
(...hex data for a 142px by 132px graphic then follows...)

The math results in the following:

picwgoal1363 / 20 = 68.15 (should be 142)
pichgoal1267 / 20 = 63.35 (should be 132)

QUESTION:
How can I accurately determine when a large graphic has been reduced in size in an RTF document, when reading the RTF stream? And, once I have deduced that fact, how can I determine what the "re-sized value" was in the RTF view of the document?

Thanks!

SB

Answer : Decipher Image Size in RTF coding (HARD ONE!!!)

I found a page http://latex2rtf.sourceforge.net/rtfspec_7.html which from my reading of the Pictures section, it would appear that the blipupi that only certain images output this information. So without this information I'd say there is no reliable way to get the information you are looking for (short of maybe trying to parse the hex code for the actual image itself...no idea how you'd go about that though).

Random Solutions  
 
programming4us programming4us