# How to convert text to image with Images.jl?

**URL:** <https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877>\
**Category:** General Usage\
**Tags:** question, images, strings\
**Created:** [March 25, 2017, 7:28pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877 "2017-03-25T19:28:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 25, 2017, 7:28pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/1 "2017-03-25T19:28:37Z")

</div>

How to convert text stored in a Julia string to an image of given size? For example, let’s say we are given the word “Julia”, how can we generate the logo with WIDTHxHEIGHT pixels?

![](https://sea2.discourse-cdn.com/julialang/images/transparent.png)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 25, 2017, 7:43pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/2 "2017-03-25T19:43:21Z")

</div>

Use a plotting package or Luxor.jl?

---

<div class="post-metadata">

**Author:** ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Post date:** [March 25, 2017, 8:23pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/3 "2017-03-25T20:23:08Z")

</div>

If you just want text over an image, ImageView.jl has an [annotation API](https://github.com/timholy/ImageView.jl#annotation-api).

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 25, 2017, 8:36pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/4 "2017-03-25T20:36:14Z")

</div>

@mkborregaard, thanks for sharing `Luxor.jl`, it looks awesome.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 25, 2017, 8:36pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/5 "2017-03-25T20:36:43Z")

</div>

@dfdx, the annotation API is very helpful, will play with it, thanks.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 25, 2017, 9:18pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/6 "2017-03-25T21:18:09Z")

</div>

Yes, it’s great - and it has a `julialogo` function to draw the julia logo (which I know isn’t what you were after but still cool 🙂 )

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [March 26, 2017, 2:07pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/7 "2017-03-26T14:07:44Z")

</div>

Wow `Luxor.jl` is so stupid amazing! But boy dojulianshateunderscores…

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 27, 2017, 4:12pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/8 "2017-03-27T16:12:05Z")

</div>

🙂

I had to stop using underscores when I used Mathematica (they’re not allowed in variable names). I had to stop using hyphens when I stopped using Lisp. I’m getting used to the [“join words when readable”](http://docs.julialang.org/en/stable/manual/style-guide/#use-naming-conventions-consistent-with-julia-s-base) style.

I missed these ones, though:

```julia
douglas_peucker()
intersection_line_circle()
paint_with_alpha()
paper_sizes()     
saved_colors

```

`#gettingusedtonotusingunderscores`

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [March 27, 2017, 4:16pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/9 "2017-03-27T16:16:41Z")

</div>

lol … oh man it will hurt when we have to do `intersectionlinecircle()` 🙂 Thanks so much for `Luxor.jl`. Been losing my mind using it lately. Love it so much. I have been thinking about trying to have it write to a `Gtk.jl` canvas, I haven’t looked at the code, but being based on Cairo do you think this would be feasible for a mortal to implement?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 27, 2017, 4:39pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/10 "2017-03-27T16:39:51Z")

</div>

It might be possible. It is very un-interactive, I agree. I tread very warily in Cairo waters, and avoid them whenever possible…

Personally I tend to focus on a simpler UI and larger and more static graphics. I think Julia should definitely offer interactive graphics, and projects such as [gtkreactive](https://github.com/JuliaGizmos/GtkReactive.jl) and [glvisualize](http://www.glvisualize.com) are probably where the future is.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [March 27, 2017, 6:13pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/11 "2017-03-27T18:13:54Z")

</div>

It’s possible, i have done this locally. I added functions to access the surface in the Luxor currentdrawing and attaching to the surface from the context in a Gtk canvas shouldn’t be problem (read as: i had a plan to do it, but got distracted by other problems, mainly v0.6 in Cairo).

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [March 27, 2017, 6:25pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/12 "2017-03-27T18:25:45Z")

</div>

sweetness! That is what I figured, from a memory long ago of working with Cairo. I will see if I can put something together!

---

<div class="post-metadata">

**Author:** ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Post date:** [March 29, 2017, 5:34pm UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/13 "2017-03-29T17:34:59Z")

</div>

the unregistered [https://github.com/JuliaGraphics/FreeTypeAbstraction.jl](https://github.com/JuliaGraphics/FreeTypeAbstraction.jl) can draw text into a matrix.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 30, 2017, 4:52am UTC](https://discourse.julialang.org/t/how-to-convert-text-to-image-with-images-jl/2877/14 "2017-03-30T04:52:36Z")

</div>

Thank you @bjarthur, one more package to add to the collection.
