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

Import photo EXIF data on upload #774

Open
psiemens opened this issue Mar 7, 2018 · 0 comments
Open

Import photo EXIF data on upload #774

psiemens opened this issue Mar 7, 2018 · 0 comments
Assignees

Comments

@psiemens
Copy link
Member

psiemens commented Mar 7, 2018

We want to automatically parse EXIF data from image files when they are uploaded to Dispatch.

Python EXIF package: https://pypi.python.org/pypi/ExifRead

The code that currently processes uploaded images is here: https://github.com/ubyssey/dispatch/blob/develop/dispatch/modules/content/models.py#L393-L413

Here's an example of basic EXIF info taken from a JPEG:

screen shot 2018-03-07 at 2 36 49 pm

The data we are interested in is:

  • title
  • caption
  • artist (equivalent to Dispatch author)
  • keywords (equivalent to Dispatch tags)

The Image model already has fields for title and authors, but you'll have to add fields for caption and tags.

When parsing the artist EXIF field, you should perform a lookup to see if a person with that name exists in the database:

# Gets or creates the person if they don't already exist
name = parse_name_from_EXIF()
person, created = Person.objects.get_or_create(full_name=name)

# You can now create a new Author instance:
author = Author.objects.create(person=person, type="photographer")

# Add the author to the Image instance
self.authors.add(author)

Note: you'll want to do the same thing for the tags field.

@wmatous wmatous self-assigned this Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants