9

I have a Rails app that I want to capture a screenshot of a webpage when the user enters a url.

  1. Is it possible to do this in Rails (is there any gem that would do this?)

  2. If not, are there any reliable services that generate live screenshots

tshepang
  • 12,111
  • 21
  • 91
  • 136
Lee
  • 627
  • 1
  • 8
  • 20

3 Answers3

11

I use IMGKit gem for that: https://github.com/csquared/IMGKit

Related topic: How to respond_to PNG or JPG in Rails and generate image from HTML?

Community
  • 1
  • 1
fl00r
  • 82,987
  • 33
  • 217
  • 237
  • It is worth mentioning that this only works for HTML with inlined CSS, and no javascript is executed. You can use a gem like `premailer` to inline your CSS, but the results aren't great. – Navid Khan May 27 '20 at 14:55
6

ScreenCap gem which uses PhantomJS under the hood. Grab whole pages or just specific divs, or even exact x y coordinates.

iamse7en
  • 609
  • 8
  • 21
2

I have used GrabzIt for this. This is quite simple.

User16119012
  • 957
  • 11
  • 25