Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up the photo and pixelated photo workflow #24

Open
bfeldman89 opened this issue Nov 26, 2020 · 2 comments
Open

clean up the photo and pixelated photo workflow #24

bfeldman89 opened this issue Nov 26, 2020 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@bfeldman89
Copy link
Owner

No description provided.

@bfeldman89 bfeldman89 added bug Something isn't working enhancement New feature or request labels Nov 26, 2020
@bfeldman89
Copy link
Owner Author

jail_scrapers/scrapers.py

Lines 493 to 501 in cbb976b

try:
img_src = urllib.parse.urljoin(main_url, soup.find('img', {'align': 'middle'})['src'])
img_src_r = requests.get(img_src)
if img_src_r.headers['Content-Type'] == 'image/jpeg':
this_dict['img_src'] = img_src
else:
print('image source isn\'t actually an image')
except TypeError:
print('no pic at this time')

would the below code be simpler, faster, more intuitive, or preferable for any other reason?

if 'No photo available at this time.' in data:
    print('no pic')
else:
    this_dict['img_src'] = f"http://www.co.hinds.ms.us/pgs/inmatephotos/{this_dict['bk']}.jpg"

@bfeldman89
Copy link
Owner Author

now that the code is blurring and reducing opacity of images upon upload to cloudinary, I need to translate into the python code the facility specific blurring/opacity settings that the airtable formula field of the prior workflow provided.

new code

try:
upload_response = uploader.upload(url, opacity=40, effect="blur:400")
# to-do: individualize opacity and blur effect for each facility
time.sleep(1)
this_dict["PIXELATED_IMG"] = [{"url": upload_response['secure_url']}]
airtab.update(record['id'], this_dict)

old airtable formula field

CONCATENATE(
    'https://res.cloudinary.com/bfeldman89/image/upload/e_pixelate_faces:', 
     IF(jail = "mcdc", "20/o_45/",
         IF(jail = "prcdf", "15/o_60/",
             IF(jail = "lcdc", "13/o_80/",
                 IF(jail = "ccdc", "5/",
                     IF(jail = "acdc", "10/", 
                         IF(jail = "jcj", "10/o_75/", 
                             IF(jail = "jcdc", "8/o_60/", 
                                 IF(jail = "jcadc", "11/o_45/", "16/o_90/"
                                 )
                             )
                         )
                     )
                 )
             )
         )
     ),
     UID,
     '.jpg'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant