Skip to content

Instantly share code, notes, and snippets.

@ascheink
Last active December 13, 2015 20:08
Show Gist options
  • Save ascheink/4967443 to your computer and use it in GitHub Desktop.
Save ascheink/4967443 to your computer and use it in GitHub Desktop.
Code to quickly create a mosaic image of the faces of the detainees still in Gitmo http://i.imgur.com/tIqdGtH.jpg
require 'nokogiri'
require 'httparty'
puts "Scraping ids of detainees in custody"
ids = []
(1..10).each do |n|
response = HTTParty.get "http://projects.nytimes.com/guantanamo/detainees/held?page=#{n}"
page = Nokogiri::HTML(response)
ids += page.css('#detaineesTable a').map { |link| $1 if /detainees\/(\d+)/ =~ link['href'] }.compact
end
puts "Grabbing WikiLeaks photos"
ids.each do |id|
url = "http://projects.nytimes.com/guantanamo/images/faces/#{"%06d" % id}.jpg"
system "wget -q #{url}" if HTTParty.get(url).code == 200
end
puts "Combining images"
system "convert -define jpeg:size=200x200 0*.jpg -thumbnail 60x60^ -gravity center -extent 60x60 square.jpg"
system "montage -geometry 60x60+0+0 -tile 15x10 square*.jpg splash.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment