Class: Smusher::SmushIt
- Inherits:
-
Object
- Object
- Smusher::SmushIt
- Defined in:
- lib/smusher/smush_it.rb
Constant Summary collapse
- URL =
How to find a new url: go to the smusher page and look for ‘files’ in the js source find then url where the ‘files’ get send + add /ws.php
'http://ypoweb-01.experf.gq1.yahoo.com/ysmush.it/ws.php'
Class Method Summary collapse
Class Method Details
.converts_gif_to_png? ⇒ Boolean
16 17 18 |
# File 'lib/smusher/smush_it.rb', line 16 def self.converts_gif_to_png? true end |
.optimized_image_data_for(file) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/smusher/smush_it.rb', line 20 def self.optimized_image_data_for(file) response = HTTPClient.post URL, 'files[]' => File.new(file) response = JSON.parse(response.body) raise "smush.it: #{response['error']}" if response['error'] image_url = response['dest'] raise "no dest path found" unless image_url open(image_url) { |source| source.read() } end |