-
Notifications
You must be signed in to change notification settings - Fork 14
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
equivalent of ImageMagick.getimageproperty()
#59
Comments
Could you give an example TIFF and/or key? You can do something like julia> img = TiffImages.load("/home/tlnagy/Downloads/example.tiff")
....
julia> img.ifds[1]
IFD, with tags:
Tag(IMAGEWIDTH, 1024)
Tag(IMAGELENGTH, 768)
Tag(BITSPERSAMPLE, UInt16[8, 8, 8, 8])
Tag(COMPRESSION, COMPRESSION_NONE)
Tag(PHOTOMETRIC, 2)
Tag(FILLORDER, 1)
Tag(STRIPOFFSETS, UInt32[8, 131080, 262152, 393224, 524296, ...])
Tag(ORIENTATION, 1)
Tag(SAMPLESPERPIXEL, 4)
Tag(ROWSPERSTRIP, 32)
Tag(STRIPBYTECOUNTS, UInt32[131072, 131072, 131072, 131072, 131072, ...])
Tag(PLANARCONFIG, 1)
Tag(RESOLUTIONUNIT, 2)
Tag(EXTRASAMPLES, 1)
Tag(SAMPLEFORMAT, UInt16[1, 1, 1, 1])
Tag(ICCPROFILE, Any[0, 0, 2, 36, 97, ...]) Accessing existing tags: julia> img.ifds[1][TiffImages.IMAGEWIDTH]
Tag(IMAGEWIDTH, 1024) Creating new tags: julia> img.ifds[1][TiffImages.IMAGEDESCRIPTION]
ERROR: KeyError: key 0x010e not found
Stacktrace:
[1] getindex
@ ~/.julia/packages/OrderedCollections/PRayh/src/ordered_dict.jl:380 [inlined]
[2] getindex
@ ~/.julia/dev/TiffImages/src/ifds.jl:30 [inlined]
[3] getindex(ifd::TiffImages.IFD{UInt32}, key::TiffImages.TiffTag)
@ TiffImages ~/.julia/dev/TiffImages/src/ifds.jl:29
[4] top-level scope
@ REPL[5]:1
julia> img.ifds[1][TiffImages.IMAGEDESCRIPTION] = "test"
"test" And if using a non-standard tag, you can always refer to it by its julia> img.ifds[1][UInt16(5678)] = "test"
"test"
julia> img.ifds[1]
IFD, with tags:
...other stuff...
Tag(UNKNOWN(5678), "test")
Tag(ICCPROFILE, Any[0, 0, 2, 36, 97, ...]) |
Also, the tag accessing API is not finalized so if you had any thoughts on how to improve the behavior, I'm open to suggestions! |
excellent, thanks! in my case, i had to take the additional step of printing the
|
Yeah, currently I truncate the output when displaying long strings to just the first 20 bytes here: Line 116 in 18e6b45
But I'm happy to consider alternative approaches. |
re-opening with a suggestion: would be nice to get the tags as described above without having to read in the entire image. mmap is the suggested work-around i suppose? an API that provides a means to get the image size, bit depth, etc. would be better. |
Mmap would certainly work in a pinch:
but it should be possible to load the tag info separately from the image data. I already load the IFD tag info separately at the beginning: Lines 12 to 16 in 18e6b45
|
i'm not familiar enough with the internals of TIFF, but for an API, at a minimum, a method which returned the image dimensions given a filename would help. specifically, in my case each plane is stored in a separate file. so i need to preallocate a 3D array, and then loop over loading each image. and to do that i need the dimensions. |
What if you could access all the ifd info as in #59 (comment), but without loading the image? We could call that function
or
Not sure which one I prefer. |
that'd be great! i'm not a TIFF expert so have no preference on your proposed alternatives. |
is there a way to do this with TiffImages.jl?
The text was updated successfully, but these errors were encountered: