HTML to JPEG with Ruby and Puppeteer

Install Puppeteer and Grover

npm i puppeteer
gem install grover

Convert HTML to JPEG and save to file

require 'grover'

File.open("html.jpg", "wb") do |f|
  f.write(Grover.new('<html><body><h1>Hello World</h1></body></html>').to_jpeg)
end

Find out how to take a retina screenshot with Ruby and Puppeteer.

We created Urlbox to make converting HTML to images easy

Learn more about our website screenshot API.