Carta - Generate images from HTML

Hi :waving_hand:,

I’m building an open source Elixir blog engine, for which I needed a way to generate OG images from HTML templates, and after having that built, I decided to extract it into a separate Elixir package.

Carta is an HTML to image Elixir package. It uses a pool of headless Chrome instances under the hood. My suggestion if you plan to use it for the same thing is that you use our provided hash to cache them in object storage and serve them from there in the future since hitting the Chrome pool for every request is inefficient.

1 Like

Hi, good library. I’ve read the code and here are my comments

  1. It creates a task mix version to bump version of project in mix.exs. I think it is out of scope of this library
  2. Templates must be EEx files on disk, its not possible to render a string template
  3. It renders only EEx templates. Its not possible to just render a ready HTML. And I think that users can handle a single EEx.eval_string |> Carta.render, so rendering a template is outside of the scope of the library. Handling template rendering over to the library user is a bit more universal approach since user may user non-EEx templates, or just use a plain HTML
  4. Have you considered using Wallaby? It has all the browser functionality you need, it supports both Selenium API and Chromium API, allowing you to render images with any modern browser
  5. I think that it would be better if users could start their browser pools manually, instead of the dependency starting the pool for them based on application configuration. Thats important because starting this dependency with pool_size: 0 in configuration results in crash:
    ** (ArgumentError) pool_size must be a positive integer, got: 0
        (nimble_pool 1.1.0) lib/nimble_pool.ex:398: NimblePool.start_link/1