Add support for loading image streams
Bug #518732 reported by
Mark Lee
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pyexiv2 |
Fix Released
|
Wishlist
|
Olivier Tilloy |
Bug Description
Currently, pyexiv2 (both 0.1.x and 0.2~bzr) only support loading images from the filesystem. I have added basic support for loading "image streams" via file-like objects (i.e., objects with the "read()" method), including unit tests.
This enhancement depends on bug 517298.
Related branches
lp:~osomon/pyexiv2/from_buffer
(Merged)
Changed in pyexiv2: | |
assignee: | nobody → Mark Lee (malept) |
importance: | Undecided → Wishlist |
status: | New → Confirmed |
status: | Confirmed → In Progress |
Changed in pyexiv2: | |
assignee: | Mark Lee (malept) → Olivier Tilloy (osomon) |
milestone: | none → 0.2 |
Changed in pyexiv2: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Hey Mark, thanks for your work on this one.
I didn't test it but I read the code, and it looks correct to me.
Supporting file-like objects sounds neat, but I was wondering what's the most common use-case, and it occurred to me that in general image manipulation libraries rather give you access to a data buffer than to a file-like interface. See for example PIL.Image, and its tostring() method (http:// www.pythonware. com/library/ pil/handbook/ image.htm# Image.tostring). Anyway, I think this use-case ought to be considered, at least as seriously as supporting file-like objects.
If we are to support different "constructors" for ImageMetadata, I would rather go for static methods than a polymorphic constructor (which implies magic code and is harder to document), e.g.:
ImageMetadata .open(filename_ or_file) .from_buffer( data)
ImageMetadata
If .open() (or .__init__()) is called with a file-like object, the file can be .read() from the python code and the data passed directly to .from_buffer(), which avoids the need for a tricky data stream constructor in C++.
I'm open to comments, critics and suggestions. Let's agree on the API before implementing it.