tiff(n)
tiff(n) β TIFF image manipulation π
okay so bestie, you've stumbled into tiff(n), the manual page for TIFF image manipulation in Tcllib, and honestly? it's giving β¨ metadata queen β¨. grab a strawberry π, sit down, and let's go through it together, because every single detail is staying, no cap.
β¨ NAME β¨
tiff β TIFF reading, writing, and querying and manipulation of meta data π
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require tiff ?0.2.3?
::tiff::isTIFF file
::tiff::byteOrder file
::tiff::numImages file
::tiff::dimensions file ?image?
::tiff::imageInfo file ?image?
::tiff::entries file ?image?
::tiff::getEntry file entry ?image?
::tiff::addEntry file entry ?image?
::tiff::deleteEntry file entry ?image?
::tiff::getImage file ?image?
::tiff::writeImage image file ?entry?
::tiff::nametotag names
::tiff::tagtoname tags
::tiff::debug file
π¦ DESCRIPTION π¦
so this package hands you the whole toolkit β query, modify, read, and write TIFF images. TIFF stands for Tagged Image File Format, and it's a standard for lossless storage of photographical images and their associated metadata. it's specified at
http://partners.adobe.com/public/developer/tiff/index.html
periodt. πΈ
one single TIFF file can hold multiple images, which is why basically every function here has an optional ?image? argument β that's your way in to any image that isn't the first one. and the data inside a TIFF image? stored as a series of tags, each with a numerical value, and each represented either as a 4 digit hexadecimal format or as a string name. if you want a reference on defined tags and what they mean, go here:
http://www.awaresystems.be/imaging/tiff/tifftags.html
iykyk π§
π COMMANDS π
::tiff::isTIFF fileβ returns a boolean value telling you iffileis a TIFF image. yes or no, iconic behaviour π::tiff::byteOrder fileβ returns eitherbigorlittle. throws an error iffileis not a TIFF image. π«Ά::tiff::numImages fileβ returns the number of images infile. throws an error iffileis not a TIFF image. lowkey the most useful count ever.::tiff::dimensions file ?image?β returns the dimensions of image number?image?infile, as a list of the horizontal and vertical pixel count. throws an error iffileis not a TIFF image. π::tiff::imageInfo file ?image?β returns a dictionary with the keysImageWidth,ImageLength,BitsPerSample,Compression,PhotometricInterpretation,ImageDescription,Orientation,XResolution,YResolution,ResolutionUnit,DateTime,Artist, andHostComputer. the values are the associated properties of the TIFF?image?infile. values may be empty if the associated tag isn't present in the file. π
puts [::tiff::imageInfo photo.tif]
and the output is giving:
ImageWidth 686 ImageLength 1024 BitsPerSample {8 8 8} Compression 1
PhotometricInterpretation 2 ImageDescription {} Orientation 1
XResolution 170.667 YResolution 170.667 ResolutionUnit 2 DateTime {2005:12:28 19:44:45}
Artist {} HostComputer {}
there is nothing special about these tags, bestie β this is simply a convience procedure which calls getEntry with common entries. throws an error if file is not a TIFF image.
::tiff::entries file ?image?β returns a list of all entries in the givenfileand?image?in hexadecimal format. throws an error iffileis not a TIFF image. π::tiff::getEntry file entry ?image?β returns the value ofentryfrom image?image?in the TIFFfile.entrymay be a list of multiple entries. if an entry does not exist, an empty string is returned. π
set data [::tiff::getEntry photo.tif {0131 0132}]
puts "file was written at [lindex $data 0] with software [lindex $data 1]"
throws an error if file is not a TIFF image.
::tiff::addEntry file entry ?image?β adds the specified entries to the image named by?image?(default0), or optionallyall.entrymust be a list where each element is a list of tag, type, and value. if a tag already exists, it is overwritten. π€
::tiff::addEntry photo.tif {{010e 2 "an example photo"} {013b 2 "Aaron F"}}
the data types are defined as follows:
1β BYTE (8 bit unsigned integer)2β ASCII3β SHORT (16 bit unsigned integer)4β LONG (32 bit unsigned integer)5β RATIONAL6β SBYTE (8 bit signed byte)7β UNDEFINED (uninterpreted binary data)8β SSHORT (signed 16 bit integer)9β SLONG (signed 32 bit integer)10β SRATIONAL11β FLOAT (32 bit floating point number)12β DOUBLE (64 bit floating point number)
throws an error if file is not a TIFF image.
::tiff::deleteEntry file entry ?image?β deletes the specified entries from the image named by?image?(default0), or optionallyall. throws an error iffileis not a TIFF image. bye bye tag π«Ά::tiff::getImage file ?image?β returns the name of a Tk image containing the image at index?image?fromfile. throws an error iffileis not a TIFF image, or ifimageis an unsupported format. supported formats are uncompressed 24 bit RGB and uncompressed 8 bit palette. π¨::tiff::writeImage image file ?entry?β writes the contents of the Tk imageimageto a tiff filefile. files are written in the 24 bit uncompressed format, with big endian byte order. additional entries to be added to the image may be specified, in the same format astiff::addEntry. βοΈ::tiff::nametotag namesβ returns a list with names translated from string to 4 digit format. 4 digit names in the input are passed through unchanged. strings without a defined tag name will throw an error. π::tiff::tagtoname tagsβ returns a list with tags translated from 4 digit to string format. if a tag does not have a defined name it is passed through unchanged. π::tiff::debug fileβ prints everything we know about the given file in a nice format. it's giving unhinged infodump and we love that for us. π£οΈ
π VARIABLES π
the mapping of 4 digit tag names to string names uses the array ::tiff::tiff_tags. the reverse mapping uses the array ::tiff::tiff_sgat. two arrays, one vibe. π―
π LIMITATIONS π
- cannot write exif ifd
- reading limited to uncompressed 8 bit rgb and 8 bit palletized images
- writing limited to uncompressed 8 bit rgb
bestie. read those three again before you start filing bugs. reading and writing are limited, this is not a skill issue on your part, it's just how the package is. π
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
this document, and the package it describes, will undoubtedly contain bugs and other problems. it's not a flaw, it's a lifestyle. π please report such in the category tiff of the Tcllib Trackers at
http://core.tcl.tk/tcllib/reportlist
please also report any ideas for enhancements you may have for either package and/or documentation. we want them, fr fr.
when proposing code changes, please provide unified diffs, i.e the output of diff -u.
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. that's the whole trick, periodt. β¨
β KEYWORDS β
image, tif, tiff
π CATEGORY π
File formats
π COPYRIGHT π
Copyright (c) 2005-2006, Aaron Faupell <afaupell@users.sourceforge.net>
okay and that's the whole page, bestie π¦ this came to you straight from tcllib, version 0.2.3, and it's the tiff(n) page β so go forth, read some tags, write some images, and slay π
β¨π
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2005-2006, Aaron Faupell <afaupell@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms