-
Notifications
You must be signed in to change notification settings - Fork 2
Images and Image Associations
Images can be uploaded from the local machine or from a Flickr album. In both cases, the images will be put in both S3 and the database. Images may also be associated with Channels or Moments using the same script. These scripts require that the configuration files have been filled out with the correct S3 and API server credentials. (When transferring images in Flickr, the Flickr API key is also required.)
To upload all the images in a folder, from the directory src/ run
python ImageUpload.py local <local folder> <S3 folder> <Mission name>
For example,
python ImageUpload.py local image-folder/ test-imgs/ "Apollo 11"
uploads all images found under image-folder including those in any subdirectories and uploads them to S3 under the folder test-imgs. They are also put in the database and associated with the Apollo 11 mission.
First, you will need to obtain the ID of the Flickr album you wish to import. This is the last number found in the URL of the album. For example, the ID of https://www.flickr.com/photos/projectapolloarchive/sets/72157659051355812 is 72157659051355812. To upload the images, from the directory src/ run
python ImageUpload.py flickr <Flickr album id> <S3 folder> <Mission name>
For example,
python ImageUpload.py flickr 72157659051355812 flickr-imgs "Apollo 11"
would upload all the images in that Flickr album to S3 under the folder flickr-imgs, and associates the images with the Apollo 11 mission.
Images uploaded to the exploreapollo system are assigned a title. Currently, this is set to the filename of the image, without the directory prefix and filetype extension. For example, path/to/image/space-pic.png receives the name space-pic. These titles must be unique, as they are used to refer to the images when associating images to Channels and Moments (detailed below). This is a deliberate design to simplify the association process by producing predictable titles. As a consequence, images may be rejected if there are two with the same name, even if they are in different directories or albums.
Images can also be associated with Channels or Moments that have already been uploaded. If images need to be associated with a Channel or Moment that has not been uploaded yet, upload those first! To upload associations, you must supply a csv file listing all the appropriate information. An example has been provided under src/examples/mediaAssociation.csv, part of which is shown here as a table.
media_title | attachable_type | attachable_title | met_start | met_end |
---|---|---|---|---|
AS11-40-5900 | Moment | Landing Sequence | 694923000 | 695000000 |
AS11-40-5906 | Moment | Splashdown |
Each row corresponds to a single association. The first column, media_title, must contain the title of the image. If the image has been uploaded using this script, the title will be exactly the image name without the filetype extension and without the directory path. For example, path/to/image/space-pic.png has the title space-pic.
The second column, attachable_type, must be either Moment or Channel, depending on what the image will be attached to.
The third column, attachable_title, must contain the title of the Moment or Channel the image will be attached to.
The last two columns are optional, and can be used to specify a time period in which the image is pertinent.
Once the csv file is filled out, the media associations can be added to the system with
python ImageUpload.py <media associations csv>
The associations can also be added at the same time that images are transferred from a local machine or Flickr, provided that all images referenced in the csv are already in the exploreapollo system or are in the new set of images.
python ImageUpload.py flickr <Flickr album id> <S3 folder> <Mission name> <media associations csv>
or
python ImageUpload.py local <local folder> <S3 folder> <Mission name> <media associations csv>
In addition to the sample csv, a Google Sheet has been set up that performs some basic sanity checks. The sheet can be found here. Note that the sheet cannot detect errors relating to references to images, Moments, and Channels that do not exist -- these errors are caught by the script when they are run.