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

Australia Local Councillors Images

This downloads a copy of images from Popolo data and saves them to S3. This is so the images are available over HTTPS and reliably available.

This runs on morph.io to ensure the images are always up to date.

The images are publicy available at:

https://australian-local-councillors-images.s3.amazonaws.com/#{Popolo ID}.jpg

Usage

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

All the expected environment variables are documented in .env.example. To test locally, copy this to .env and replace values with real ones. To run the script first install gems:

bundle

Then run:

bundle exec dotenv ruby scraper.rb

To speed things up, you can specify an Australian state or territory to target using the environment variable ENV["MORPH_TARGET_STATE"], e.g.:

MORPH_TARGET_STATE=sa

You can also target a specific organization by id using ENV["MORPH_TARGET_ORGANIZATION"], e.g.:

MORPH_TARGET_ORGANIZATION=legislature/city_of_unley

Resizing the images

This scraper can also save a resized version of the images as a JPEG. You can configure the width, and the height of the image you’d like to save using environment variables:

MORPH_RESIZE_IMAGES=true
MORPH_RESIZE_WIDTH=80
MORPH_RESIZE_HEIGHT=88
# Reprocess and save the resized images
MORPH_CLOBBER_RESIZED_IMAGES=false