I would like to add annotations to a pixel graphics. The text should be in vector font and whatever graphics I add (e.g., lines) should be in vector format, too. Let's take a simple example:

im = Graphics[{Red, Circle[{0, 0}, 100]}, ImageSize -> 200];
rec = Graphics[{Black, Rectangle[{0, 0}, {50, 5}]}, ImageSize -> 50];
text = Graphics[{Black, Text["some text"]}, ImageSize -> 100];
ov = ImageCompose[ImageCompose[im, rec, {150, 55}], text, {150, 65}];
Export["test.pdf", ov]

Let's say that im is a pixel graphics and I can't do anything about that (in reality for instance an imported png file), but the overlaid text and rectangle are mathematica objects and I want them to be rendered as vector objects. Is that possible with mathematica?


1 Answer 1


Yes, you can. Use Show to combine appropriate graphics objects, then Export to a vector-capable format like PDF, and you'll see that the text and graphics are retained in vector format:

 ExampleData[{"TestImage", "Airplane2"}],
   Red, Rectangle[{100, 100}, {210, 140}],
     Style["some text", 32, White, Background -> Blue],
     Scaled[{0.3, 0.75}]

Export["test.pdf", %]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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