Just enough to get you going with adding a text overlay with rmagick:

marcgg.com/blog/2020…

(my favorite kind of blog post … the fiddly bits + enough to establish the pattern.