How to convert text to image with Images.jl?

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?

1 Like

Use a plotting package or Luxor.jl?

6 Likes

If you just want text over an image, ImageView.jl has an annotation API.

2 Likes

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

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

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 :slight_smile: )

2 Likes

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

2 Likes

:slight_smile:

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” style.

I missed these ones, though:

douglas_peucker()
intersection_line_circle()
paint_with_alpha()
paper_sizes()     
saved_colors

#gettingusedtonotusingunderscores

2 Likes

lol … oh man it will hurt when we have to do intersectionlinecircle() :slight_smile: 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?

1 Like

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 and glvisualize are probably where the future is.

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).

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

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

1 Like

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