"Images in RTF"
In the RTF Pocket Guide's section on "Embedding Images", I say this:
In an ideal world, RTF would allow you to insert a picture into a
document by simply dropping a hex-encoded GIF, JPEG, or PNG file into
your RTF code. But RTF doesn't do things that way. The RTF
specification, on the subject of pictures, explains a {\pict...}
construct that contains picture data (typically as a long series of
hexadecimal digits).
And the crucial sentence:
But the picture data encoded in the {\pict...} construct is in a binary
format that can't be converted to easily from a conventional image
format (i.e., GIF, JPEG, or PNG).
The binary format that I'm talking about is actuall WMF (Windows
Metafile), incidentally -- whenever I'd try dropping a gif into a
document and the examining how it saved, it'd be encased in inscrutible
WMF code (or, even worse, MSWord-specific binary formats). One can,
I'm sure, convert GIF to WMF, but not easily.
But a reader of mine, Dave Thielen, has pointed out to me something that
totally escaped me, my experienced tech-editors, and everyone
else I've ever asked about this (and I asked far and wide) -- namely,
that the contents of a {\pict...} construct CAN be in an WMF, OR
they can be in JPG or PNG (and a few other uninteresting formats
besides). That is, whereas you can't dump raw GIF data into a \pict
construct, you CAN dump raw JPG/PNG data in -- encoded as hex data,
and prefaced by the image heigh and width.
(Actually, you can use unencoded data as part of a \binN keyword, but
this is probably a bad idea for various minor pragmatic reasons, and is
in any case not covered in the book.)
Specifically, you use {\pict\jpegblip\picwX\pichY...} or
{\pict\pngblip\picwX\pichY...} where X is the image's width in pixels
and Y is the image's height in pixels. The content is simply hex
encoded. I suggest adding a newline every so often -- I like adding
one every 64 characters, and maybe even before and after the data
as a whole.
This approach is demonstrated by the rtf_image_embed_sample.pl program
in this directory, and its sample input files hypnocat.jpg and
hypnocat.png, and output files hypnocat_jpg.rtf and hypnocat_png.rtf.
You can stick other, optional, commands between the \pichY and the
picture data. Consult the RTF specification's section "Pictures"
for all the gory details, but here's a quick reference to the
eight interesting ones:
\picwgoalN
Desired width of the picture, in twips.
\pichgoalN
Desired height of the picture, in twips.
\picscalexN
Horizontal scaling value. The N argument is a value representing a
percentage (the default is 100 percent).
\picscaleyN
Vertical scaling value. The N argument is a value representing
a percentage (the default is 100 percent).
\piccroptN
\piccropbN
\piccroprN
\piccroplN
The top, bottom, right, and left cropping values, in twips.
A positive value crops toward the center of the picture; a negative
value crops away from the center, adding a space border around the
picture (the default value is 0).
Remember, that's just quick reference; the spec is more detailed, mostly
for options that used only with embedding image types other than PNG and
JPG.
Gefunden in
http://examples.oreilly.com/rtfpg/
dies wiederum gefunden auf
http://www.oreilly.com/catalog/rtfpg/
dies wiederum gefunden auf
http://search.cpan.org/~sburke/RTF-Writer-1.11/lib/RTF/Cookbook.pod
dies wiederum gefunden auf
http://search.cpan.org/~sburke/RTF-Writer-1.11/
dies wiederum gefunden auf
http://search.cpan.org/~sburke/
dies wiederum gefunden auf
http://interglacial.com/~sburke/
dies wiederum gefunden auf
http://groups.google.de/groups?selm=e7m43503DHA.1636@TK2MSFTNGP12.phx.gbl
dies wiederum gefunden per Google-Groups-Suche nach "html2rtf".