try: e = browser.find_element_by_name('imageDescription[' + str(photo_id) + ']') except: print "We've reached all the images we could find" end_id = photo_id - 1 break urllib.urlretrieve(image_url, str(photo_id) + '.jpg') image1 = Image.open(str(photo_id) + '.jpg') images = find_images('thumbnails') photo_id += 1 photo_id = orig_photo_id for i in images: digest1 = pHash.image_digest(str(photo_id) + '.jpg', 1.0, 1.0, 180) digest2 = pHash.image_digest(str('thumbnails/' + i), 1.0, 1.0, 180) if pHash.crosscorr(digest1, digest2) == 1: if photo_id < end_id: photo_to_id[photo_id] = i photo_id += 1 print name_to_num for ident in photo_to_id: repl = re.sub('IMG_', '', str(photo_to_id[ident])) photo_num = re.sub('.jpg', '', repl) if name_to_num[photo_num]: try: e = browser.find_element_by_name("imageDescription[" + str(ident) + "]") e.send_keys(name_to_num[photo_num]) except: print "Sorry couldn't find that element " + str(ident) try:
#!/usr/bin/env python # coding: utf-8 import sys import pHash if __name__ == "__main__": if len(sys.argv) != 3: print "usage: ${prog} src dst" sys.exit(0) d1 = pHash.image_digest(sys.argv[1], 1.0, 1.0, 180) d2 = pHash.image_digest(sys.argv[2], 1.0, 1.0, 180) print 'digest', pHash.crosscorr(d1, d2)[1] h1 = pHash.imagehash(sys.argv[1]) h2 = pHash.imagehash(sys.argv[2]) print 'hash', pHash.hamming_distance(h1, h2)
image_url = str(photo_url + str(photo_id) + "_102_73_1.jpg") try: e = browser.find_element_by_name('imageDescription[' + str(photo_id) + ']') except: print "We've reached all the images we could find" end_id = photo_id - 1 break urllib.urlretrieve(image_url, str(photo_id) + '.jpg') image1 = Image.open(str(photo_id) + '.jpg') images = find_images('thumbnails') photo_id += 1 photo_id = orig_photo_id for i in images: digest1 = pHash.image_digest(str(photo_id) + '.jpg', 1.0, 1.0, 180) digest2 = pHash.image_digest(str('thumbnails/' + i), 1.0, 1.0, 180) if pHash.crosscorr(digest1, digest2) == 1: if photo_id < end_id: photo_to_id[photo_id] = i photo_id += 1 print name_to_num for ident in photo_to_id: repl = re.sub('IMG_', '', str(photo_to_id[ident])) photo_num = re.sub('.jpg', '', repl) if name_to_num[photo_num]: try: e = browser.find_element_by_name("imageDescription[" + str(ident) + "]") e.send_keys(name_to_num[photo_num]) except: print "Sorry couldn't find that element " + str(ident) try: e = browser.find_element_by_value("Spara")
#!/usr/bin/env python import sys import pHash if __name__ == "__main__": src = sys.argv[1] dst = sys.argv[2] d1 = pHash.image_digest(src, 1.0, 1.0, 180) d2 = pHash.image_digest(dst, 1.0, 1.0, 180) print pHash.crosscorr(d1, d2)[1]
import pHash import sys hash1 = pHash.imagehash(sys.argv[1]) hash2 = pHash.imagehash(sys.argv[2]) print 'Hamming distance: %d (%08x / %08x)' % (pHash.hamming_distance( hash1, hash2), hash1, hash2) digest1 = pHash.image_digest(sys.argv[1], 1.0, 1.0, 180) digest2 = pHash.image_digest(sys.argv[2], 1.0, 1.0, 180) print(pHash.crosscorr(digest1, digest2))