Skip to content

Instantly share code, notes, and snippets.

@sudipidus
Created December 15, 2017 10:41
Show Gist options
  • Select an option

  • Save sudipidus/d789169900ef7332f4e99ef17fb8fceb to your computer and use it in GitHub Desktop.

Select an option

Save sudipidus/d789169900ef7332f4e99ef17fb8fceb to your computer and use it in GitHub Desktop.
import json
import os
from PIL import Image
from urllib.request import urlopen
import csv
min_width = 800
min_height = 500
min_quality = 3
def validate(uri_list):
quality_count = 0
result = ''
for each_uri in uri_list:
im = Image.open(
urlopen(each_uri.replace(' ','%20')))
if ((im.width>=min_width) and (im.height>=min_height)):
quality_count = quality_count +1
else:
result = result + each_uri +' is of low quality '
with open('results.csv', 'a') as csvfile:
resultwriter = csv.writer(csvfile, dialect='excel')
resultwriter.writerow([str(id), result])
uri_list = ['https://s3-ap-southeast-1.amazonaws.com/vacation.rentals/67817/88506/182/download (1).png']
id = 1
if __name__=='__main__':
validate(id, uri_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment