Skip to content

Instantly share code, notes, and snippets.

@abscondment
Created July 22, 2011 16:16
Show Gist options
  • Save abscondment/1099761 to your computer and use it in GitHub Desktop.
Save abscondment/1099761 to your computer and use it in GitHub Desktop.
phash notes
# ruby-1.9.2-p180 :001 > require 'mini_magick'
# => true
# ruby-1.9.2-p180 :002 > i = MiniMagick::Image.open('sample.jpg')
# => #<MiniMagick::Image:0x000000015bc448 @path="/tmp/mini_magick20110721-11512-ru54lb.jpg", @tempfile=#<File:/tmp/mini_magick20110721-11512-ru54lb.jpg (closed)>>
# ruby-1.9.2-p180 :003 > i.resize '8x8'
# => ""
# ruby-1.9.2-p180 :004 > i.type 'Grayscale'
# => ""
# ruby-1.9.2-p180 :005 > i.write 'out.jpg'
####
require 'RMagick'
image = Magick::Image.read('out.jpg') do |i|
i.colorspace = Magick::ColorspaceType.values[2]
end
image = image[0]
image.view(0,0,8,8)
# http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
# http://stackoverflow.com/questions/4777070/hamming-distance-on-binary-strings-in-sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment