vitalie / webshot

Captures a web page as a screenshot.
MIT License
214 stars 68 forks source link

MiniMagick::Error for some sites #7

Open arsenische opened 10 years ago

arsenische commented 10 years ago

Thanks for a great gem! I used it to fetch images of thousands of sites. But for some sites it always returns the following error:

Webshot::Screenshot.instance.capture("http://bitcoinplanet.yolasite.com/", "/tmp/thumb.png")
MiniMagick::Error: Command ("identify -quiet -ping /tmp/mini_magick20140924-2486-17g09z6.png") failed: {:status_code=>1, :output=>"identify.im6: improper image header `/tmp/mini_magick20140924-2486-17g09z6.png' @ error/png.c/ReadPNGImage/3675.\n"}
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:381:in `run'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:363:in `run_command'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:171:in `valid?'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:140:in `create'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:48:in `read'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:111:in `block in open'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
    from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
    from <...>/bundle/ruby/2.0.0/gems/webshot-0.0.7/lib/webshot/screenshot.rb:56:in `capture'
    from (irb):2
    from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in `start'
    from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands/console.rb:8:in `start'
    from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

ruby 2.0 phantomjs 1.9.7 webshot 0.0.7 capybara 2.4.3 poltergeist 1.5.1 ubuntu 14.04.1 LTS

arsenische commented 9 years ago

The error disappears if to remove ":full => true" from https://github.com/vitalie/webshot/blob/c16d0a5bd30572369239a5a28bfa55bff0b67dcf/lib/webshot/screenshot.rb#L53

Perhaps it just doesn't have enough memory to create an image file?

vitalie commented 9 years ago

Hi Arsen,

I'm busy this week, I'll take a look at this issue on Monday.

Thank you, Vitalie

rgo commented 9 years ago

@arsenische try the new version with the updated mini_magick and poltergeist (it worked for us)