openaustralia / australian_local_councillors_images

Stores a copy of Australian local councillor images from Popolo on S3. Runs on morph.io
https://morph.io/openaustralia/australian_local_councillors_images
0 stars 0 forks source link

Make images available at the size we're displaying them on planning alerts #5

Closed henare closed 8 years ago

henare commented 8 years ago

We're displaying them at 80x88 on PlanningAlerts. We should continue to fetch and cache the original image at the current URL and make a new one at #{popolo_id}-80x88.jpg.

https://github.com/jpmckinney/image-proxy will probably come in handy.

equivalentideas commented 8 years ago

I've now got an instance of the image-proxy deployed to play with http://fast-escarpment-97115.herokuapp.com/http%3A%2F%2Fwww.bmcc.nsw.gov.au%2Ffiles%2FABennett_photo.gif/100/100.jpeg

It does the resizing and transcodes all images to .jpeg .

I'm gonna now have a crack with the scraper at running images through the proxy and also saving a resized version of the image.

equivalentideas commented 8 years ago

I'll look up the url scheme that gravitar use for predictable resizing.

equivalentideas commented 8 years ago

I'll look up the url scheme that gravitar use for predictable resizing.

Hhmmm—Gravitar use the query string, which feels wrong for us since we're not responding to queries on the file, but rather returning a specific file.

Something like this seem quite predictable:

https://australian-local-councillors-images.s3.amazonaws.com/blacktown_city_council/len_robinson_80x88.jpg
henare commented 8 years ago

The space replacement in our Popolo IDs is an underscore. As I suggested above, I'd use a different separator between the ID and the size so you know it's a different attribute, e.g. blacktown_city_council/len_robinson-80x88.jpg.

equivalentideas commented 8 years ago

Thanks @henare 👍

equivalentideas commented 8 years ago

I've got this working with https://github.com/openaustralia/australian_local_councillors_images/compare/48935fa7717b...b4c765aabf9b , but I'm going to make it a bit more configurable to live up to what our readme says:

The code is fairly generic and all the configuration is stored in environment variable so you should be able to repurpose this quite easily.

equivalentideas commented 8 years ago

Ok, I've made this much more configurable.

Here's an example of this in action. Hmmm. for some reason github wont show them. Here's the links

Original cached: https://australian-local-councillors-images.s3.amazonaws.com/bathurst_regional_council/greg_westman.jpg

Resized to 80 x 88: https://australian-local-councillors-images.s3.amazonaws.com/bathurst_regional_council/greg_westman-80x88.jpg

scraped from from:

henare commented 8 years ago

Spiffy! :tada: