Enter your target URL:

Library for Ruby and Rails

We provide a library for Ruby and for Rails. The Ruby gem makes it easy to download your thumbnails, while the Rails plugin adds a custom tag thumbalizr_url to generate the Thumbalizr URL right inside your templates.

Quick code sample

The ruby code to generate a Thumbalizr URL is pretty simple, you can easily copy and paste it into your project:

require 'url'
require 'digest'

def thumbalizr(url='', options={})
  embed_key = 'MY_EMBED_API_KEY' # replace it with you Embed API key
  secret = 'MY_SECRET' # replace it with your Secret
  
  query = 'url=' + CGI::escape(url.to_s)
  
  options.each_pair do |key, value|
    query += "&#{key}=" + CGI::escape(value.to_s)
  end
  
  token = Digest::MD5.hexdigest(query + secret)
  
  
  return "https://api.thumbalizr.com/api/v1/embed/#{embed_key}/#{token}/?#{query}"
end


puts thumbalizr("https://browshot.com/", {:width => 300, :size => 'page' })
puts thumbalizr("google.com")

Download code sample

Ruby gem

You can install the thumbalizr gem by adding gem "thumbalizr", ">= 0" to your Gemfile. You'll find the source code in GitHub

Your API key and Secret can be found in the member section after you sign up for a free account.

#!/usr/bin/env ruby

require 'thumbalizr'

client = Thumbalizr.new('MY_EMBED_API_KEY', 'MY_SECRET')  # replace it with you Embed API key and Secret

url = client.url('https://www.thumbalizr.com/?1')
puts "#{url}\n\n"

results = client.download_wait(url, "test.png");
puts "Image downloaded to #{results[:image]} - #{results[:result]}\n";

Download code sample

Rails extension

Add the thumbalizr-rails gem to your Rails project to use the thumbalizr_url custom tag in your templates. First, add the library to your Gemfile:

# Gemfile
gem 'thumbalizr-rails'

Then, initialize ThumbalizrClient in a new file config/initializers/thumbalizr.rb:

# Create config/initializers/thumbalizr.rb
ThumbalizrClient.config("MY_KEY", "MY_SECRET")

Now, you can call thumbalizr_url inside your templates to generate the Thumbalizr URL of your thumbnails. You can pass any of the API parameters listed in the API documentation page.

<img src="<%= thumbalizr_url('https://www.google.com/', {:country => 'us', :width =>  400}) %> "> 

You can find the source of the Rails extension on GitHub.