2

Whenever I try to output PNGs with metapost, I get really bizarre outputs. For reference, I'm using Windows 7 with MiKTeX 2.9.

The metapost code I'm using is adapted from the metafont example on the latter's wikipedia page:

outputformat := "png";
outputtemplate := "%j-%c.%o";

beginfig(1);
    h=100;
    w=100;
    y1=y2=y3=0;
    y4=y5=y6=h;
    x1=x4=0;
    x2=x5=w;
    x3=x6=2*w;
    pickup pencircle xscaled 0.2w yscaled 0.04w rotated 45;
    draw z1..z3..z6{z2-z6}..z5..{z4-z2}z4..cycle;
endfig;
end.

When I generate eps files, the output works fine (the code is the same as above, save for substituting 'eps' for 'png'). Here is a screenshot of the eps output:

enter image description here

However, when I try to generate a PNG, this is what I get:

enter image description here

I have no clue what's going on, and I haven't been able to find any reference to this specific problem.

  • 1
    It seems to be the combination of pencircle and rotate 45. With pensquare all is well or you can fiddle with the rotation. (Actually, this gives an inkling what's happening I think - try varying the angle.) – cfr May 30 '16 at 1:26
  • 1
    Thank you for the report. I have added an issue at tracker.luatex.org/view.php?id=976 – Luigi Scarso May 30 '16 at 8:22
  • @LuigiScarso oh, thanks! I guess I just assumed I was doing something wrong, but this does appear to be some sort of bug. – Kevin Keith May 30 '16 at 9:08
  • As a workaround, you could use Imagemagick to convert .eps to .png. This works very reliably with MP output. – Thruston May 30 '16 at 23:45
  • 1
    It should be fixed in rev. 2102 . – Luigi Scarso Nov 23 '16 at 7:23
1

Well, it looks like this is a bug in Metapost. The solution I came up with was to simply write a shell script which takes the EPS output and converts it into PNG with ghostscript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.