Screenshot of a particular quality with Ruby and Puppeteer

Install Puppeteer and Grover

npm i puppeteer
gem install grover

Configure Grover

Note that the quality is a number between 0 and 100 and is ignored if the output is not a JPEG.

require 'grover'

Grover.configure do |config|
  config.options = {
    screenshot: {
      type: 'jpeg',
      quality: 75
    },
  }
end

Take a screenshot of the resized viewport and save to file

File.open("quality.jpg", "wb") do |f|
  f.write(Grover.new('https://www.bbc.co.uk/news/business-63709754').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.