RubyGem for webthumb
Webthumb is a service to create thumbnails from websites (descriptive name, isn’t it…). It creates different sized thumbnails by default and you can request custom sizes.It offers an API to access it’s services and we wrapped up some code i wrote while on vacation and bundled it as a gem.The code is still a bit clumsy (as i wrote it on vacation :-) ) but it works nice for us. There is already another ruby wrapper for the API but it is not available as a RubyGem and does not expose some of the latest webthumb functionalities so we decided to write our own library. Josh gave us some extra credits so we could develop the API. Thanks. The gem is available on Simplificator’s github repo. To install do following:
sudo gem update --system (in case you are not yet on version 1.2.0 or higher)
sudo gem sources -a http://gems.github.com (only once)
sudo gem install simplificator-rwebthumb
To create thumbnails:
require 'rubygems'
require 'rwebthumb'
include Simplificator::Webthumb
# main access point for the Webthumb API
wt = Webthumb.new('YOUR API KEY HERE')
job = wt.thumbnail(:url => 'http://simplificator.com')
job.write_file(job.fetch_when_complete(:large), '/tmp/test.jpg')
For more info check the README file and (currently) the source code. All the features from a the request element are supported but currently not documented. I’ll look into that in some days.If you want to use the Gem you’ll need an account for webthumb. You’ll get 100 free credits every month so it’s easy to try it out.
back
July 11th, 2008 at 14:09
[...] web applications « RubyGem for webthumb [...]
August 22nd, 2008 at 14:16
Also make sure you sudo gem install tzinfo.
Alex
August 24th, 2008 at 9:44
Hey Alex
tzinfo is mentioned as dependency. It is used to convert from MST to UTC time.
I added it in installation section to make sure everything is working..
Pascal
October 9th, 2009 at 22:07
On Thursday Oct. 8 around 10AM PDT the bluga service had “queueing issues”. As a result our requests tot he service using the ruby webthumb API entered endless loops. This is because the fetch_when_complete method continued in an endless loop as long as it was able to get valid responses from the server (presumably the response that says “still working on it”).
The bluga site is fixed and should not have such issues but there is always the chance something else will happen to the service.
I am going to modify/monkey patch Simplificator::Webthumb::Job.fetch_when_complete to take a timeout parameter so that it doesnt check in an endless loop forever.
If you want the modification, can you send me an email with some instructions on where to send the modified code?
Thanks, Mike