Main Content

setDirectory

Make specified IFD the current IFD

Description

setDirectory(t,dirNum) sets the image file directory (IFD) specified by dirNum as the current IFD. Tiff object functions operate on the current IFD.

example

Examples

collapse all

Navigate the image file directories (IFDs) in a TIFF file and get tag or image data from the different IFDs.

Create a Tiff object for the file example.tif which contains three IFDs and display the directory index number for the current IFD in the file.

t = Tiff('example.tif','r');
currentDirectory(t)
ans = 
1

Change the current IFD to 2 and get the value of the ImageDescription tag.

setDirectory(t,2);
getTag(t,'ImageDescription')
ans = 
'First image converted to grayscale.'

Change the current IFD to 3 and get the value of the ImageDescription tag.

setDirectory(t,3);
getTag(t,'ImageDescription')
ans = 
'Credit:  Jeff Mather and Alex Taylor.'

Close the Tiff object.

close(t);

Input Arguments

collapse all

Tiff object representing a TIFF file. Use the Tiff function to create the object.

Directory index number, specified as a one-based positive integer.

Example: 2

Data Types: double

Algorithms

collapse all

References

This function corresponds to the TIFFSetDirectory function in the LibTIFF C API. To use this function, you must be familiar with the TIFF specification and technical notes. View this documentation at LibTIFF - TIFF Library and Utilities.

Version History

Introduced in R2009b