I'm using MetaUML to create text-driven UML diagrams. When I generate a figure, with:

$ mpost example.mp
$ convert ps:example.1 png:example.png

a very low-resolution image is generated. If I scale the postscript image up using ImageMagick's convert utility, it is blurry (obviously sampled up from low-res source data). Additionally, if I change the defaultscale parameter in the MetaUML source, all text will be increased in size but it will overlap with other text. Additionally at large values for defaultscale, the text will extend beyond the UML boxes.

Here's the complete MetaUML source I'm using:

prologues := 2; % needed to load font definitions
defaultscale := 1.0 % I tweaking this value doesn't do what I want
input metauml; % load the MetaUML library
    Class.B("Point") % class name
        ("#x:int", "#y:int") % attributes
        ("+set(x:int, y:int)", % operations
    B.e = A.w + (-20, 0);
    drawObjects(A, B);
    link(inheritance)(B.e -- A.w);

How do I make the pipeline (MetaUML -> Metapost -> convert) yield higher resolution images?

  • 1
    convert -quality 90 -density 600 ps:example.1 png:example.png would be better, probably. – egreg Dec 17 '13 at 21:06
  • @egreg - That absolutely did it. Post as an answer and you win! – Ron Dahlgren Dec 17 '13 at 21:08
  • I wonder why you create a vector image and then rasterise it? – Marco Dec 17 '13 at 21:13
  • @Marco - The end goal is a PNG. I'm not familiar with this toolchain. What would you recommend? – Ron Dahlgren Dec 17 '13 at 21:14
  • Don't rasterise a vector image if not strictly required. Depending on your requirements you can convert it to PDF, PostScript or SVG. I personally mostly go for PDF. – Marco Dec 17 '13 at 21:18

I would rather convert the Postscript file to PDF, so you don't lose vector information. Use a bitmap format such as PNG only if there's no other choice.

You can improve the result of the bitmap file by running convert with a high -density parameter, and also by using a high -quality:

convert -quality 90 -density 600 ps:example.1 png:example.png

This will create a 600dpi image, rather than the default 72dpi.

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.