IMGKit icon indicating copy to clipboard operation
IMGKit copied to clipboard

Is there a way to take snapshot of a website when it's fully loaded?

Open jiarongxu opened this issue 11 years ago • 3 comments

My Code :

    resource = Resource.find_by_id(resource_id)
    kit   = IMGKit.new(url, 'load-error-handling' => 'ignore')
    img   = kit.to_img(:png)
    file  = Tempfile.new("template_"+resource_id.to_s+'.png', 'tmp',
                           :encoding => 'ascii-8bit')
    file.write(img)
    file.flush

    resource.image = file

    if resource.save
      file.unlink
    end

When it makes snapshot of some website with loading, it immediately saves the loading screen to the image, is there way to wait until the website is fully loaded, then save it to image?

jiarongxu avatar Nov 13 '13 17:11 jiarongxu

i am facing same issue.

mistrikushal avatar Mar 27 '14 06:03 mistrikushal

same problem here, sometimes it generates without some images that were not loaded yet

rafaelp avatar Nov 23 '14 21:11 rafaelp

Are those images loading via JS or via normal embeds like and css? You can tell wkhtmltoimage to wait for js with teh --javascript-delay <msec> flag. Checkout wkhtmltoimage -H for more resources.

csquared avatar Dec 17 '14 00:12 csquared