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

Add Metadata extraction and make this and the target size available for filters. #661

Merged
merged 3 commits into from Feb 15, 2016
Merged

Add Metadata extraction and make this and the target size available for filters. #661

merged 3 commits into from Feb 15, 2016

Conversation

sbaechler
Copy link
Contributor

I created a filter for Thumbor that adds the possibility for responsive art direction using the universal images XMP metadata standard. An example of the filter output can be seen on the demo page.

For the filter to work I had to fork Thumbor and make some modifications to the BaseEngine and the Transformer classes. If the pyexiv2 library is available, then Thumbor extracts all metadata (not just Exif) from the image and stores it in the metadata property. Unfortunately, the Engine.init method is the only place that has access to the original image metadata. Pillow strips it from the image data.

The filter needed the target size as well. I therefore added a getter method to the Transformer class and instantiated the class before the AFTER_LOAD filters are run. Those filter have access to the transformer instance and the target size.

This pull request solves issue #625.

There are two versions of the pyexiv2 library. The original one which is available for Python 2 (via homebrew or apt-get) and py3exiv2 for Python 3.

move metadata initialization to base engine

move metadata extraction to base engine

make transformer available in AFTER_LOAD filters

make target dimensions available in the context
@guilhermef
Copy link
Member

@sbaechler Travis is not running the tests with: pyexiv2

@sbaechler
Copy link
Contributor Author

python-pyexiv2 and python py3exiv2 are not whitelisted in TravisCI yet. I opened a request for whitelisting them. This might take a while (usually about a week). I'll check back in a few days. Sorry for spamming the Slack channel, but the notification code is hardcoded in travis.yml.

@sbaechler
Copy link
Contributor Author

TravisCI whitelisted python-pyexiv2 and the build is passing with the new library.
https://travis-ci.org/sbaechler/thumbor/jobs/109013961

Py3exiv2 is going to take a while longer because they have to whitelist the package repository first.

guilhermef added a commit that referenced this pull request Feb 15, 2016
Add Metadata extraction and make this and the target size available for filters.
@guilhermef guilhermef merged commit 6a1671b into thumbor:master Feb 15, 2016
christianjgreen pushed a commit to fanhero/thumbor that referenced this pull request Aug 29, 2017
Add Metadata extraction and make this and the target size available for filters.
@jimas14 jimas14 mentioned this pull request Feb 18, 2021
@jimas14
Copy link

jimas14 commented Feb 25, 2021

@sbaechler How can pyexiv2 be available if py3 was introduced in thumbor v7?

@sbaechler
Copy link
Contributor Author

@jimas14 This pull request was merged 5 years ago. At that time it worked. I haven't used thumbor recently.

@jimas14
Copy link

jimas14 commented Mar 1, 2021

@sbaechler I understand, thanks for your response. I'm just confused how pyexiv2 was available at the time you merged this. When I try running the server with thumbor==6.7.0 and python==3.7 (so pyexiv2 can be installed) there are lots of version/syntax errors. And when I try running with thumbor==6.7.0 and python==2.7, pyexiv can't be installed due to version.

I'm trying to customize the engine init to allow IPTC to pass through, or at least copy some relevant IPTC fields into exif before returning. It's related to EU laws about copyright requirements (https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000038835832/2019-10-24%20%5blegifrance.gouv.fr%5d).

If you or @kkopachev have 10 mins to chat with me about this, I would greatly greatly greatly greatly appreciate it.

@sbaechler
Copy link
Contributor Author

@jimas14 When I wrote the plugin, Thumbor was still at 6.0.0 and worked with Python 2.

I cannot remember it, but here is the readme for my plugin: https://github.com/sbaechler/thumbor-universalimages. It references Python 2 and Thumbor 6.0.0.

@jimas14
Copy link

jimas14 commented Mar 1, 2021

@sbaechler I've seen that but didn't realize until today that apt-get install python-pyexiv2 is how pyexiv2 is available with python 2.7.

I appreciate your follow-up on this 5-year old PR, you're a saint

@sbaechler
Copy link
Contributor Author

@jimas14 You are welcome.

I think I also got it to work with Python 3 since I asked Travis CI for whitelisting the Py3exiv2 package. I could however not find the code.

I did find my heroku project that thad the thumbor server configuration: https://github.com/sbaechler/thumbor-rmd-demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants