This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-06
Channels
- # adventofcode (2)
- # announcements (5)
- # architecture (4)
- # babashka (35)
- # beginners (28)
- # calva (4)
- # cider (9)
- # clerk (30)
- # clj-kondo (11)
- # clojure (58)
- # clojure-conj (3)
- # clojure-europe (71)
- # clojure-gamedev (2)
- # clojure-nl (3)
- # clojure-uk (2)
- # clojurescript (49)
- # conjure (2)
- # cursive (2)
- # emacs (4)
- # fulcro (1)
- # honeysql (2)
- # hyperfiddle (10)
- # jobs (2)
- # jobs-discuss (18)
- # leiningen (9)
- # membrane (14)
- # missionary (1)
- # off-topic (27)
- # pedestal (1)
- # polylith (5)
- # reagent (12)
- # releases (2)
- # remote-jobs (3)
- # shadow-cljs (83)
- # sql (5)
- # squint (14)
- # tools-build (13)
Does anyone know of a library that can convert text into an image (e.g. png)? I have found code examples in Java, but it feels like there should be a Java library somewhere out there that I can use from Clojure.
It looks like it can manipulate images. I want to create images from e.g. the output from different shell commands. And I want to include that into a tool, that I build in Clojure, so a Java or Clojure library would solve my problem. After a quick look at ImageMagic, it didn't seem to support that.
I know how the output will look like, so converting text to an image is what I really need (as a library).
@U1G0HH87L I bet you could do it with https://github.com/HumbleUI/Skija
Would just be a case of saving the buffer I assume? cc @U050UBKAA
You could generate an SVG which is a relatively straightforward XML format. You can then convert SVG to png/gif/jpeg etc. One approach is to create an SVG using an SVG editor like Inkscape. Then find/replace strings in the SVG XML using clojure.
I think Skia is better (given it's the rendering engine in Chrome) and is used for SVG renderings etc. You're just skipping the outsourcing step.
I assume @U1G0HH87L you've already found https://github.com/HumbleUI/Skija/blob/master/examples/bitmap/src/RenderToBitmap.java
Here is the example of usage in case of typography https://github.com/genmeblog/genuary/blob/master/src/genuary/2022/day17.clj
Will look into that also. Thanks!
Yeah, if it works for your use case Clojure2D is probably better because you don't have to worry about shipping native binaries. Skia is a powerful alternative though.
I do a https://github.com/clj-commons/rewrite-clj/blob/d6d7885fc573dda35ddc06428ae2a9c199f00f50/script/doc_update_readme.clj#L133-L150 on some of the projects I work on with https://github.com/clj-commons/etaoin to generate https://github.com/clj-commons/rewrite-clj/tree/main#contributors for folks who contribute. Works well enough for my use case. Basically: -> hiccup->html/css->browser->screenshot. It's a bit heavy tho, ya? And can sometimes render very slightly differently with a new browser release.
AWT has support for doing this without any external libraries. https://www.baeldung.com/java-add-text-to-image
This was just an exercise, I know there is the pulsar library. There is also Akka for the JVM, but sadly it was turned into a comercial product by Lightbend
I wanted to manage impure stuff from Java libraries in a concurrently safe way and figured out Clojure agents are not ideal for that. Then I realized with some effort I can use Go blocks like actors
That's why Lisps are better than other languages. If I want something baked into the language, first I write a very detailed email to Brian Goetz, then I pray he will read and be convinced
Then I wait 15 years for the JEP to be accepted. in Clojure I just have to write macros lol
Clojure has agents which are like actors right?
Agents are similar, but they expose the state to anyone be able to deref @
ohh gotcha
shows what I know 😆
An actor state is completely protected from external access, you have to send a message and ask the actor
In Akka you can keep the actor state mutable and dirty, as long the messages are immutable. Clojure agents only accept immutable values as state