I like the idea of generating OpenGraph images based on some template. SVG structure looks customizable to me, so I tried to use .svg as an OG image and failed. OpenGrapgh does not support this format.
I have Rails app deployed to Heroku. I found a great idea of how to automate OG image creation here.
What we have to do:
- Create an SVG template (use ERB to support variables);
- Add mini_magic or similar lib for SVG to JPG conversion;
- Create a rake task for generating JPG from SVG;
- Add rake task to Heroku scheduler;
Created rake task will generate and attach JPG to model (will be uploaded to AWS); Rake task should find records without attached OG image. Sometimes you need to regenerate OG image, so it will be nice to have record-marking functionality.
This flow allows us to have an SVG template for the OG image, and also will separate CPU consumption (scheduler will use separate Dyno instance).
Top comments (0)