Extending TiffImages.jl
If you want to extend TiffImages.jl to add support for more features or change how TIFF data is loaded, you have come to right place.
Types
TiffImages.TiffFile — Type
mutable struct TiffFile{O<:Unsigned, S<:FileIO.Stream}-> TiffFile
Wrap io with helper parameters to keep track of file attributes.
uuid: A unique identifier for this filefilepath: The relative path to this fileio: The file streamfirst_offset: Location of the first IFD in the file streamneed_bswap: Whether this file has a different endianness than the host computer
TiffImages.IFD — Type
struct IFD{O<:Unsigned}An image file directory is a sorted collection of the tags representing this plane in the TIFF file. They behave like dictionaries except that tags aren't required to be unique, so given an IFD called ifd, we can add new tags as follows:
julia> ifd[TiffImages.IMAGEDESCRIPTION] = "Some details";
julia> ifd[TiffImages.IMAGEWIDTH] = 512;
julia> ifd
IFD, with tags:
Tag(IMAGEWIDTH, 512)
Tag(IMAGEDESCRIPTION, "Some details")Tags are not required to be unique! See TiffImages.Iterable for how to work with duplicate tags.
TiffImages.Tag — Type
struct Tag{T}In-memory representation of Tiff Tags, which are essentially key value pairs. The data field can either be a String, a Number, an Array of bitstypes, or a RemoteData type.
tagdata
TiffImages.Iterable — Type
A wrapper to force getindex to return the underlying array instead of only the first element. Usually the first element is sufficient, but sometimes access to the array is needed (to add duplicate entries or access them).
julia> using TiffImages: Iterable
julia> ifd[TiffImages.IMAGEDESCRIPTION] = "test"
"test"
julia> ifd[Iterable(TiffImages.IMAGEDESCRIPTION)] # since wrapped with Iterable, returns array
1-element Vector{TiffImages.Tag}:
Tag(IMAGEDESCRIPTION, "test")
julia> ifd[Iterable(TiffImages.IMAGEDESCRIPTION)] = "test2" # since wrapped with Iterable, it appends
"test2"
julia> ifd
IFD, with tags:
Tag(IMAGEDESCRIPTION, "test")
Tag(IMAGEDESCRIPTION, "test2")
TiffImages.RemoteData — Type
RemoteDataA placeholder type to describe the location and properties of remote data that is too large to fit directly in a tag's spot in the IFD. Calling TiffImages.load! on an IFD object replaces all RemoteDatas with the respective data.
position: Position of this data in the streamcount: The length of the data
Functions
TiffImages.load! — Function
load!(tf, ifd)
Updates an TiffImages.IFD by replacing all instances of the placeholder type TiffImages.RemoteData with the actual data from the file tf.
Base.sizeof — Function
sizeof(file)Number of bytes that file's header will use on disk
sizeof(tag::TiffImages.Tag)Minimum number of bytes that the data in tag will use on disk.
sizeof(ifd)Number of bytes that an IFD will use on disk.