Skip to content

Commit

Permalink
Merge pull request #20 from jasonpettus/parsing-feeds
Browse files Browse the repository at this point in the history
Bug fix on image size parser to handle 64-bit images
  • Loading branch information
bwootten committed Jul 19, 2015
2 parents 9a36d54 + 4714fbe commit 98fc4ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ gem 'nokogiri'
gem 'fastimage'
gem 'open_uri_redirections'
gem 'mechanize'
gem 'image_info'

gem 'text'

Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ GEM
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
ethon (0.7.4)
ffi (>= 1.3.0)
execjs (2.5.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
Expand All @@ -88,11 +90,16 @@ GEM
faraday_middleware (~> 0.9)
loofah (~> 2.0)
sax-machine (~> 1.0)
ffi (1.9.10)
globalid (0.3.5)
activesupport (>= 4.1.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
image_info (1.0.0)
image_size
typhoeus
image_size (1.4.1)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
Expand Down Expand Up @@ -210,6 +217,8 @@ GEM
tins (1.5.4)
turbolinks (2.5.3)
coffee-rails
typhoeus (0.7.2)
ethon (>= 0.7.4)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
Expand Down Expand Up @@ -239,6 +248,7 @@ DEPENDENCIES
factory_girl_rails
fastimage
feedjira
image_info
jbuilder (~> 2.0)
jquery-rails
mechanize
Expand Down
18 changes: 14 additions & 4 deletions app/models/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ def get_feature_imgs(articles) # => Takes 13s for 20 articles from "http://rss.n

agent = Mechanize.new
page = agent.get(article_url).images.each do |img|
all_img_urls << img.src
dimensions = FastImage.size(img.src)
dimensions ? area = dimensions.reduce(1) { |length, width| length * width } : area = 0
img_areas << area
p ">" * 25
p img
p ">" * 25
img_src = img.src
if img_src
all_img_urls << img_src
img = ImageInfo.from(img_src)[0]
img ? area = img.size.reduce(1) { |length, width| length * width } : area = 0
img_areas << area
else
all_img_urls << "NONE"
img_areas << 0
end

end

largest = img_areas.index(img_areas.max)
Expand Down

0 comments on commit 98fc4ef

Please sign in to comment.