Last active
September 1, 2017 10:07
-
-
Save dtinth/ee452a1451b4328634fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
require 'erb' | |
title, subtitle, *text, image_number = ARGV | |
output_file = "image%02d.cover.png" % [image_number.to_i] | |
html = ERB.new(File.read('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}'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><meta charset=utf-8> | |
<style> | |
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; | |
} | |
</style> | |
</head><body> | |
<div id="outer"> | |
<div id="inner"> | |
<div class="title"><%= title %></div> | |
<div class="subtitle"><%= subtitle %></div> | |
<div class="text"><%= text.join('<br>') %></div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment