1tiff(n) TIFF image manipulation tiff(n)
2
3
4
5______________________________________________________________________________
6
8 tiff - TIFF reading, writing, and querying and manipulation of meta
9 data
10
12 package require Tcl 8.2
13
14 package require tiff ?0.2.1?
15
16 ::tiff::isTIFF file
17
18 ::tiff::byteOrder file
19
20 ::tiff::numImages file
21
22 ::tiff::dimensions file ?image?
23
24 ::tiff::imageInfo file ?image?
25
26 ::tiff::entries file ?image?
27
28 ::tiff::getEntry file entry ?image?
29
30 ::tiff::addEntry file entry ?image?
31
32 ::tiff::deleteEntry file entry ?image?
33
34 ::tiff::getImage file ?image?
35
36 ::tiff::writeImage image file ?entry?
37
38 ::tiff::nametotag names
39
40 ::tiff::tagtoname tags
41
42 ::tiff::debug file
43
44______________________________________________________________________________
45
47 This package provides commands to query, modify, read, and write TIFF
48 images. TIFF stands for Tagged Image File Format and is a standard for
49 lossless storage of photographical images and associated metadata. It
50 is specified at http://partners.adobe.com/public/developer/tiff/in‐
51 dex.html.
52
53 Multiple images may be stored in a single TIFF file. The ?image? op‐
54 tions to the functions in this package are for accessing images other
55 than the first. Data in a TIFF image is stored as a series of tags hav‐
56 ing a numerical value, which are represented in either a 4 digit hexa‐
57 decimal format or a string name. For a reference on defined tags and
58 their meanings see http://www.awaresystems.be/imaging/tiff/tiff‐
59 tags.html
60
62 ::tiff::isTIFF file
63 Returns a boolean value indicating if file is a TIFF image.
64
65 ::tiff::byteOrder file
66 Returns either big or little. Throws an error if file is not a
67 TIFF image.
68
69 ::tiff::numImages file
70 Returns the number of images in file. Throws an error if file
71 is not a TIFF image.
72
73 ::tiff::dimensions file ?image?
74 Returns the dimensions of image number ?image? in file as a list
75 of the horizontal and vertical pixel count. Throws an error if
76 file is not a TIFF image.
77
78 ::tiff::imageInfo file ?image?
79 Returns a dictionary with keys ImageWidth, ImageLength, BitsPer‐
80 Sample, Compression, PhotometricInterpretation, ImageDescrip‐
81 tion, Orientation, XResolution, YResolution, ResolutionUnit,
82 DateTime, Artist, and HostComputer. The values are the associ‐
83 ated properties of the TIFF ?image? in file. Values may be empty
84 if the associated tag is not present in the file.
85
86
87 puts [::tiff::imageInfo photo.tif]
88
89 ImageWidth 686 ImageLength 1024 BitsPerSample {8 8 8} Compression 1
90 PhotometricInterpretation 2 ImageDescription {} Orientation 1
91 XResolution 170.667 YResolution 170.667 ResolutionUnit 2 DateTime {2005:12:28 19:44:45}
92 Artist {} HostComputer {}
93
94
95 There is nothing special about these tags, this is simply a con‐
96 vience procedure which calls getEntry with common entries.
97 Throws an error if file is not a TIFF image.
98
99 ::tiff::entries file ?image?
100 Returns a list of all entries in the given file and ?image? in
101 hexadecimal format. Throws an error if file is not a TIFF im‐
102 age.
103
104 ::tiff::getEntry file entry ?image?
105 Returns the value of entry from image ?image? in the TIFF file.
106 entry may be a list of multiple entries. If an entry does not
107 exist, an empty string is returned
108
109
110 set data [::tiff::getEntry photo.tif {0131 0132}]
111 puts "file was written at [lindex $data 0] with software [lindex $data 1]"
112
113
114 Throws an error if file is not a TIFF image.
115
116 ::tiff::addEntry file entry ?image?
117 Adds the specified entries to the image named by ?image? (de‐
118 fault 0), or optionally all. entry must be a list where each
119 element is a list of tag, type, and value. If a tag already ex‐
120 ists, it is overwritten.
121
122
123 ::tiff::addEntry photo.tif {{010e 2 "an example photo"} {013b 2 "Aaron F"}}
124
125
126 The data types are defined as follows
127
128 1 BYTE (8 bit unsigned integer)
129
130 2 ASCII
131
132 3 SHORT (16 bit unsigned integer)
133
134 4 LONG (32 bit unsigned integer)
135
136 5 RATIONAL
137
138 6 SBYTE (8 bit signed byte)
139
140 7 UNDEFINED (uninterpreted binary data)
141
142 8 SSHORT (signed 16 bit integer)
143
144 9 SLONG (signed 32 bit integer)
145
146 10 SRATIONAL
147
148 11 FLOAT (32 bit floating point number)
149
150 12 DOUBLE (64 bit floating point number)
151
152 Throws an error if file is not a TIFF image.
153
154 ::tiff::deleteEntry file entry ?image?
155 Deletes the specified entries from the image named by ?image?
156 (default 0), or optionally all. Throws an error if file is not
157 a TIFF image.
158
159 ::tiff::getImage file ?image?
160 Returns the name of a Tk image containing the image at index
161 ?image? from file Throws an error if file is not a TIFF image,
162 or if image is an unsupported format. Supported formats are un‐
163 compressed 24 bit RGB and uncompressed 8 bit palette.
164
165 ::tiff::writeImage image file ?entry?
166 Writes the contents of the Tk image image to a tiff file file.
167 Files are written in the 24 bit uncompressed format, with big
168 endian byte order. Additional entries to be added to the image
169 may be specified, in the same format as tiff::addEntry
170
171 ::tiff::nametotag names
172 Returns a list with names translated from string to 4 digit for‐
173 mat. 4 digit names in the input are passed through unchanged.
174 Strings without a defined tag name will throw an error.
175
176 ::tiff::tagtoname tags
177 Returns a list with tags translated from 4 digit to string for‐
178 mat. If a tag does not have a defined name it is passed through
179 unchanged.
180
181 ::tiff::debug file
182 Prints everything we know about the given file in a nice format.
183
185 The mapping of 4 digit tag names to string names uses the array
186 ::tiff::tiff_tags. The reverse mapping uses the array
187 ::tiff::tiff_sgat.
188
190 [1] Cannot write exif ifd
191
192 [2] Reading limited to uncompressed 8 bit rgb and 8 bit palletized
193 images
194
195 [3] Writing limited to uncompressed 8 bit rgb
196
198 This document, and the package it describes, will undoubtedly contain
199 bugs and other problems. Please report such in the category tiff of
200 the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
201 also report any ideas for enhancements you may have for either package
202 and/or documentation.
203
204 When proposing code changes, please provide unified diffs, i.e the out‐
205 put of diff -u.
206
207 Note further that attachments are strongly preferred over inlined
208 patches. Attachments can be made by going to the Edit form of the
209 ticket immediately after its creation, and then using the left-most
210 button in the secondary navigation bar.
211
213 image, tif, tiff
214
216 File formats
217
219 Copyright (c) 2005-2006, Aaron Faupell <afaupell@users.sourceforge.net>
220
221
222
223
224tcllib 0.2.1 tiff(n)