Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

liisberg-consulting/thumbnail_scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

detect, fetch and generate a thumbnail for any url and store it on s3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages