Skip to content

Instantly share code, notes, and snippets.

@dtinth dtinth/title.rb
Last active Sep 1, 2017

What would you like to do?
require 'base64'
require 'erb'
title, subtitle, *text, image_number = ARGV
output_file = "image%02d.cover.png" % [image_number.to_i]
html ='title.template.html.erb')).result(binding)
data_url = "data:text/html;base64,#{Base64.strict_encode64(html)}"
RASTERIZE = "/usr/local/share/phantomjs/examples/rasterize.js"
system "phantomjs #{RASTERIZE} '#{data_url}' '#{output_file}'"
<!DOCTYPE html><meta charset=utf-8>
body { padding: 0; margin: 0; }
#outer {
width: 1632px; height: 1224px;
color: white; background: black;
font: bold 192px/1.3 Helvetica Neue, sans-serif;
position: relative;
#inner {
position: absolute; top: 50%; left: 0; right: 0;
-webkit-transform: translateY(-50%);
text-align: center;
padding: 32px;
.title { color: #faf543; }
.subtitle { }
.text {
font-weight: normal;
font-size: 70%;
line-height: 1.15;
margin-top: 1ex;
<div id="outer">
<div id="inner">
<div class="title"><%= title %></div>
<div class="subtitle"><%= subtitle %></div>
<div class="text"><%= text.join('<br>') %></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.