[metapost] Including an image into a metapost figure

L. Nobre G. nobre at cii.fc.ul.pt
Thu Dec 21 12:47:30 CET 2006

On 21/12/06, Stephan Hennig <mailing_list at arcor.de> wrote:
> j.romildo at gmail.com schrieb:
> > I need to draw a figure in metapost and this figure will be
> > constructed with images in an extern format (png). How can I "draw"
> > an extern image on my metpost figure?
> The exteps package supports the inclusion of eps files in MetaPost.
> About the best way to convert png to eps I don't know and the UK-TeX-FAQ
> doesn't seem to address that issue.  But maybe others can give some
> pointers.

I can:
1) the "netpbm" package contains the "pnmtops" command which can
convert "pnm" images to postscript.
2) the "imagemagick" package contains the "convert" command which can
convert almost any image format to almost any other format.

> Alternatively, would it be possible to generate the external graphic in
> vector format?  Since you're speaking about png instead of jpg at least
> it doesn't seem to be a photo image.

If to "generate", one has to "convert", then "autotrace" or "potrace" can help.
Once there is a postscript external graphic, one can use "pstoedit" to
actually produce MetaPost code. And code can... be... well, you
The page
contains a link to a lex scanner
that can further tweak the MetaPost output of "pstoedit" (in standard
PstoeditMpostPreeditor < pstoeditoutput.mp >  lexscanned.mp
where "PstoeditMpostPreeditor" is the executable compiled from the lex
scanner (compile with
flex -o PstoeditMpostPreeditor.c PstoeditMpostPreeditor.lex;\
gcc PstoeditMpostPreeditor.c -o PstoeditMpostPreeditor -ll ).

I'm sorry. I tend to publicize stuff I did...
L. Nobre G. - http://lnobreg.googlepages.com/
"In the end, self-limitation is the only answer that counts, but that
is the answer that no one wants to hear. So we sit, and wait, and
assume, and deny." Richard Heinberg in Powerdown

More information about the metapost mailing list