Repository navigation
option to read tiff metadata - #1995
jenniferdai1 wants to merge 2 commits into
Conversation
|
Let's do:
|
d6e635a to
29f8156
Compare
| Additional keyword arguments to pass through (see ``tifffile``'s | ||
| ``imread`` function). | ||
|
|
||
|
Sorry, could you explain what you mean by "separate" metadata reader? I was trying to follow your suggestion in the comment thread ("Some options:.....") Thank you for your input! |
|
Hi Jennifer! First of all, thanks for tackling this, I'll be very happy to see it resolved! Secondly, what I meant was, write a (potentially private) function that reads only metadata, and then say: def imread_metadata(filename):
return imread(filename), _metadata(filename)I think that would be cleaner than expanding the imread function itself. Thirdly, although I agree with @stefanv that we should limit the number of options (from the Zen of Python: "There should be one-- and preferably only one --obvious way to do it."), I don't agree with the best choice here, and my preference would be And finally, thanks for including a good test from the get-go, but I would like to specifically make sure that the case that started this (inverted values) works, so could you add:
Thank you! |
|
@jni If we add the "metadata=False/True" flag, then I think we should not have imread_metadata implemented. For me, it's one or the other. I'm not a big fan of functions that use a flag to change the type of output they provide, hence my preference for |
|
@stefanv I agree that it's one or the other, and I also have only a small bias towards the kwarg. For me, it just seems more natural that this would be part of the imread function rather than a separate function, and I like to keep my tab-completion clean. =) Perhaps we can just have a vote? @emmanuelle @JDWarner @ahojnnes @blink1073 ? For context, we are trying to decide whether to return image metadata using a separate function ( Actually, I just thought of another argument in favour of the kwarg: the option to read metadata should probably generalise to |
|
I prefer the approach taking by "Reads an image from the specified file. Returns a numpy array, which comes with a dict of meta data at its ‘meta’ attribute." |
|
@blink1073 I like that idea! It actually crossed my mind but then I was like nooooo, are we even allowed to do that??? =P |
|
Remember the Image object that got deprecated around 0.9? :)
Let's stick to standard structures and go with the keyword argument.
|
|
@stefanv very good point — super easy to lose the metadata when it's in some undocumented extra field. |
|
+1 for sticking with standard structures :-). I'd slightly prefer the separate function, but I don't have a strong dislike of the kw argument either. |
d2275d2 to
c0494e2
Compare
| Passed to the given plugin. | ||
|
|
||
| """ | ||
| # Backward compatibility |
There was a problem hiding this comment.
Is backward compatibility needed for a completely new function too ?
|
So, I notice that the The metadata that is exposed by the function can be added based on requirement, otherwise Also, the tiff tags mentioned at tiff tags have: Comments, Model (The model of the scanner), Artist, TargetPrinter, XMP, BatteryLevel, Copyright, ICCProfile, GPSInfo, and a whole lot of information that an image processing toolkit wouldn't care about. This seems like unnecessary noise. To read that sort of meta-information, the user should actually use an exif/meta reader like exiftool, gexiv2, etc. |
|
@AbdealiJK Agreed that we should have a set of standard meta-data, and then perhaps a custom or raw entry that contains everything the reader can provide. |
|
See #2709 |
addressing issue #1940
Automatic inversion of binary image stored as TIFFILE
created imread_metadata, imread_with_metadata, and imread(include_metadata = False) methods in tifffile_plugin.py, as suggested in a comment in the issue thread
added a new method, asarray_with_metadata, in tifffile.py that returns the image array along with a list of metadata dictionaries for each page.
Returns metadata dictionary for first page by default, like how tifffile returns the first image series by default.