Skip to content

Instantly share code, notes, and snippets.

@mscoutermarsh
Last active September 3, 2018 16:00
Show Gist options
  • Save mscoutermarsh/4fef956808a2a73b088f8e4c827e6519 to your computer and use it in GitHub Desktop.
Save mscoutermarsh/4fef956808a2a73b088f8e4c827e6519 to your computer and use it in GitHub Desktop.
Ruby - convert html/css to an image
require "httparty"
# Retrieve your user id and api key from the Dashboard https://htmlcsstoimage.com/dashboard
auth = { username: 'user_id', password: 'api_key' }
html = "<div class='ping'>Pong ✅</div>"
css = ".ping { padding: 20px; font-family: 'sans-serif'; }"
image = HTTParty.post("https://hcti.io/v1/image",
body: { html: html, css: css },
basic_auth: auth)
# => {"url"=>"https://hcti.io/v1/image/bde7d5bf-f7bb-49d9-b931-74e5512b8738"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment