def filter_pic(url): try: file = urllib2.urlopen(url).read() content_type, width, height = imageInfo.getImageInfo(file) if width > 200 and height > 200: return url else: print 'image didnt pass the filter' print url return None except ValueError: print 'could not filter' print url return None except urllib2.HTTPError: print 'could not filter' print url return None except AttributeError: print 'could not filter' print url return None except: print 'could not filter' print url return None
def filter_pic(url): global pic_count try: file = urllib2.urlopen(url).read() except ValueError: return None except urllib2.HTTPError: return None except AttributeError: return None content_type, width, height = imageInfo.getImageInfo(file) if width > 200 and height > 200: print "added pic" pic_count += 1 return url else: return None