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.TiffFileType
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 file

  • filepath: The relative path to this file

  • io: The file stream

  • first_offset: Location of the first IFD in the file stream

  • need_bswap: Whether this file has a different endianness than the host computer

source
TiffImages.IFDType
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")
Note

Tags are not required to be unique! See TiffImages.Iterable for how to work with duplicate tags.

source
TiffImages.TagType
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.

  • tag

  • data

source
TiffImages.IterableType

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")
source
TiffImages.RemoteDataType
RemoteData

A 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 stream

  • count: The length of the data

source

Functions

Base.sizeofFunction
sizeof(file)

Number of bytes that file's header will use on disk

source
sizeof(tag::TiffImages.Tag)

Minimum number of bytes that the data in tag will use on disk.

Note

Actual space on disk will be different because the tag's representation depends on the file's offset. For example, given a 2 bytes of data in tag and a file with UInt32 offsets, the actual usage on disk will be sizeof(UInt32)=4 for the data + tag overhead

source
sizeof(ifd)

Number of bytes that an IFD will use on disk.

source