Repository is archived
No commit activity in last 3 years
No release in over 3 years
detect and fetch an image suitable as a thumbnail for any url
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Thumbnail Scraper

detect, fetch and generate a thumbnail for any url

Basic usage

require 'thumbnail_scraper'

include ThumbnailScraper
scraper = ThumbnailScraper.new
image = scraper.image_to_thumbnail_for_url("http://www.example.com/")
thumbnail_url = image.url

ThumbnailScraper#image_to_thumbnail_for_url method returns Image object, which contains its size and url.

Suggested usage

We encourage you to use it with delayed_job as jobs queue and dragonfly as image storage tool. Your job could look like following:

require 'thumbnail_scraper'

module Jobs
  class ScrapeThumbnailJob < Struct.new(:page)
    def perform
      scraper = ::ThumbnailScraper::ThumbnailScraper.new
      image = scraper.image_to_thumbnail_for_url(page.url)
      page.thumbnail_url = image.url.to_s
      page.save!
    end
  end
end