sergio

sergio

Generate images with name initials using Elixir and ImageMagick

https://sergiotapia.me/generate-images-with-name-initials-using-elixir-and-imagemagick-374eca4d14ff


Hope this saves you guys some time! Using ImageMagick and some fancy flags is all you need to generate nice initial avatars for your users.

Most Liked

kip

kip

ex_cldr Core Team

Thanks for the motivation to fix a couple of bugs in Image. As of version 0.26.0 its easier to generate text-based avatars and to produce either square or circular avatars.

There’s no specific support for text-based background color generation but that might be interesting to add to the Image.Color module.

iex> Image.avatar!("./test/support/images/Kip_small.jpg", shape: :square)

iex> Image.avatar!("./test/support/images/Kip_small.jpg", shape: :circle)

iex> Image.Text.text!("KC", background_fill_color: :cyan, font_size: 200, padding: 80) 
...> |> Image.avatar!(shape: :square) 

iex> Image.Text.text!("KC", background_fill_color: :cyan, font_size: 200, padding: 80) 
...> |> Image.avatar!(shape: :circle) 

Since Image is based on vix and libvips the code is fast and memory efficient. Definitely faster than using ImageMagick since vix is NIF based. And generally considered more secure that ImageMagick too.

11
Post #9
sergio

sergio

Thank you random chinese bot scraper website! I lost my old blog and now I can recover this post!

maz

maz

I made a new package that uses your PNG generation code:

Where Next?

Popular in Guides/Tuts Top

marcelo
I wrote a small article on how to use current_user with coherence on Phoenix. There are already a couple of blogposts about it but I thin...
New
fuelen
Hi all! Just want to share a small code snippet which allows writing CASE expressions using macro which is similar to cond. Here is an ...
New
dennisreimann
I wrote a guide for implementing Passwordless Authentication a.k.a. “Magic Login Links”: https://dennisreimann.de/articles/phoenix-passw...
New
OvermindDL1
Ran across this recently, it’s a set of cheatsheet inforgraphic things of the OTP behaviours on the BEAM: https://github.com/Telichkin/o...
New
WolfDan
So my main OS is Windows, I do must of my work with it, Elixir and vscode elixirls works just fine when you’re working only with elixir, ...
New
dkuhlman
For those of you who might be interested in using ZeroMQ in Elixir, I converted the Erlang examples in the ZeroMQ “zguide” to Elixir. I ...
New
lukertty
Install web-mode and mmm-mode first and put this in your config file: (require 'mmm-mode) (require 'web-mode) (setq mmm-global-mode 'may...
New
magnetic
Hey :waving_hand:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and ...
New
Morzaram
Hey guys I’ve made a guide on how to connect Quill to Phoenix. For the sake of formatting it might be easier to view it on my Notion Doc...
New
njwest
In the process of developing a Phx-based multiplayer experience, I found myself with so many browser tabs open with Elixir gaming resourc...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42158 114
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement