# How to programmatically create and save an image with some text?

**URL:** <https://discourse.julialang.org/t/how-to-programmatically-create-and-save-an-image-with-some-text/55086>\
**Category:** General Usage\
**Created:** [February 11, 2021, 8:24pm UTC](https://discourse.julialang.org/t/how-to-programmatically-create-and-save-an-image-with-some-text/55086 "2021-02-11T20:24:12Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 12, 2021, 9:04am UTC](https://discourse.julialang.org/t/how-to-programmatically-create-and-save-an-image-with-some-text/55086/4 "2021-02-12T09:04:48Z")

</div>

In Luxor I have problems to center the text string: [How to center a text with Luxor - #2 by cormullion](https://discourse.julialang.org/t/how-to-center-a-text-with-luxor/55125/2)

So I went back to Compose, but not speaking Lisp, it looks very scaring.  
I have tried this, but the text doesn’t go on top of the rectangle:

```julia

using Colors, Compose
set_default_graphic_size(300px,300px)
img = compose(context(units=UnitBox(0,0,2,2)),
  compose(compose(context(), rectangle()), fill("white")),
  (context(), text(1, 1, "123", hcenter, vcenter), stroke("red"), fontsize(30pt)),
)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-programmatically-create-and-save-an-image-with-some-text/55086)._
