Coder Social home page Coder Social logo

vvzen / parse-exr-header Goto Github PK

View Code? Open in Web Editor NEW
33.0 6.0 9.0 33 KB

Pure Python (no additional dependencies) helper module to read metadata from the header of OpenEXR files.

License: MIT License

Python 100.00%
python27 python openexr metadata-extraction vfx python3

parse-exr-header's Introduction

parse-exr-header

license

Pure Python (no additional dependencies) helper functions to read metadata from the header of EXR files.

Reasons

In the VFX world we've got tons of great open source initiatives, like ILM's OpenEXR and Sony's OpenImageIO. Both are great C++ projects (and OIIO also provides bindings for Python), so I definitely recommend using them.

BUT maybe your package manager doesn't have a specific version and compiling them from scratch can be a long process that could get you stuck in many, many different & non well documented cmake issues.

If you only need to do something as trivial as reading the metadata of an EXR file and you don't need to do any image manipulation stuff, it's just not worth the hassle. That's why I've written this very small python module (currently ~360 LOCs) that simply reads the header of an exr file, according to the official EXR documentation available here: https://www.openexr.com/documentation/openexrfilelayout.pdf (now moved to https://openexr.com/en/latest/OpenEXRFileLayout.html)

Dependencies

Optional, for tests: pytest==4.2.0

Optional, for formatting: yapf==0.30.0

Support

Python version

This repo now supports both Python2.7 and also Python3.8. Thanks to jonaskluger for providing python3 support.

Multipart files

Support for multipart files is on its way but it will need a bit of work since the original design of this hobby project was a bit naive. A PR is currently pending.

Install

This script is not packaged in any fancy way. Just grab the parse_metadata.py and put it wherever you want.

Update (2021/12/27): Now there is also a tiny cli (bin/vv-exr-metadata) that you can use, if you want, to list the metadata of a file from a shell session. It supports the wildcard notation (*) if you want to look at multiple files at once.

Tests

I'm not a TDD guy (yet) - so there are very few tests. I'm planning to write more of them as soon as I can breathe a little. You can run tests by typing: pytest tests from the root dir of this repo.

You will need also the git submodule that contains all the exr images, so you need to clone the repo like this:

git clone --recurse-submodules [email protected]:vvzen/parse-exr-header.git

PR & Bugs

Fill free to submit Pull Requests if you notice anything wrong. I'm more than happy to merge them and adapt them to my coding style (which is just PEP8 stuff with some additional things like lowercase functions args in order to distinguish arguments from variables inside the scope of a function - very useful in my opinion and blog post coming soon).

Note: Whenever you submit a PR, the CI should automatically run the tests for you using Github Actions.

Formatting

I use yapf to end all style wars and let it do all of the formatting for me. After you made a PR, you can run it like this:

yapf --in-place src/*.py

This of course requires you to have yapf installed locally or somewhere in your $PATH. Yapf will simply read the .style.yapf file that is hosted in this repo and format the file according to these rules.

parse-exr-header's People

Contributors

barkofdelight avatar jonaskluger avatar vvzen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

parse-exr-header's Issues

Terrific work!

Not an actual issue, just a thank-you. Having unsuccessfully attempted something similar myself, I can appreciate how much of a headache this is!

In particular, thanks for the attention given to chromaticities metadata -- it's data I'm specifically interested in, yet it's surprisingly often ignored or cast to a string by other exr metadata-scraping implementations, I guess owing to the unusual datatype...

๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.