[metapost] Including graphics in MP
Laurence.Finston at gmx.net
Laurence.Finston at gmx.net
Thu May 18 10:31:24 CEST 2023
Hello,
Is it possible to include PostScript graphics, or literal PostScript in general, in MP files?
The purpose is to composite multiple images with correct alignment.
It's possible to do this in TeX (see below), but it would be nice to be able to do this directly in MP.
I've determined that this doesn't work:
%prologues := 3;
%outputtemplate := "%j_%c.ps";
outputformat:="png";
outputformatoptions:="format=rgb antialias=none";
outputtemplate := "%j_%c.png";
verbatimtex \input epsf etex;
path q[];
beginfig(1);
q0 = (unitsquare scaled 2cm) shifted (-1cm, -1cm);
draw q0 withpen pencircle scaled .333mm;
label(btex \vbox{\hbox{\epsffile{testdot1.eps}}} etex, origin);
endfig;
end;
It fails silently and the resulting PNG file is just a white square (see attachment). It doesn't work with EPS output, either.
It does work to do this in TeX:
\input epsf
\parindent=0pt
\parskip=0pt
\baselineskip=0pt
\advance\hoffset by -1in
\advance\voffset by -1in
\nopagenumbers
\def\epsfsize#1#2{#1}
\vbox to 0pt{\vskip2cm\hbox to 0pt{\hskip1cm
\epsffile{testdot1.eps}\hss}\vss}
\vbox to 0pt{\vskip2cm
\hbox to 0pt{\hskip1cm\epsffile{testdot2.eps}\hss}\vss}
\vfil\eject
\bye
The result is in `testinclude.pdf' (attached).
Any help would be much appreciated.
Laurence Finston
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testdot.mp
Type: application/octet-stream
Size: 473 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20230518/f27ae6fd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testinclude.pdf
Type: application/pdf
Size: 1293 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20230518/f27ae6fd/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testinclude1_1.png
Type: image/png
Size: 292 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20230518/f27ae6fd/attachment.png>
More information about the metapost
mailing list.