0

Here I want to take a screenshot of an external url, and I use IMGkit with CarrierWave.

  #Class Micropost
  after_create :take_snapshot     
  def take_snapshot
    file = Tempfile.new(["template_#{self.id.to_s}", 'jpg'], 'tmp', :encoding => 'ascii-8bit')
    file.write(IMGKit.new(self.external_url).to_jpg)
    file.flush
    self.snapshot = file
    self.save
    file.unlink
  end

and the screenshot get generated is..... enter image description here

So whats wrong with it?

ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
  • I just create a Rails app and was able to create a screenshot without any problem. What version of wkhtmltoimage did you install? Mine installed `0.10.0 rc2` – Jesse Wolgamott Jun 02 '13 at 16:57
  • wkhtmltox-0.11.0_rc1-installer.exe for windows – ZK Zhao Jun 03 '13 at 14:48
  • OK, soooo sorry to say, but your problem is either: 1) on windows or 2) try to get the 0.10.0 rc2 installed. – Jesse Wolgamott Jun 03 '13 at 14:52
  • @JesseWolgamott I'm having trouble in push it to heroku, do you have any idea? http://stackoverflow.com/questions/16975269/permission-denied-when-using-imgkit-on-heroku-do-we-need-to-precompile-binary-o – ZK Zhao Jun 20 '13 at 03:42
  • @JesseWolgamott and is there any examples that I can follow? I changed to 0.10.0 rc2 but still get the mosaic looking – ZK Zhao Jun 20 '13 at 03:47
  • use https://github.com/bradphelan/wkhtmltopdf-heroku – Jesse Wolgamott Jun 20 '13 at 12:46
  • @JesseWolgamott, but in IMGKIT, it requires `wkhtmltoimage`, which this gem does not provide – ZK Zhao Jun 21 '13 at 14:34
  • Ahh yes, please follow the heroku instructions on https://github.com/csquared/IMGKit and/or https://github.com/csquared/IMGKit/issues/31 – Jesse Wolgamott Jun 21 '13 at 18:12

0 Answers0