::jpeg::isJPEGfile
Returns a boolean value indicating if file is a JPEG image.
::jpeg::imageInfofile
Returns a dictionary with keys version, units, xdensity, ydensity, xthumb, and ythumb. The values
are the associated properties of the JPEG image in file. Throws an error if file is not a JPEG
image.
::jpeg::dimensionsfile
Returns the dimensions of the JPEG file as a list of the horizontal and vertical pixel count.
Throws an error if file is not a JPEG image.
::jpeg::getThumbnailfile
This procedure will return the binary thumbnail image data, if a JPEG thumbnail is included in
file, and the empty string otherwise. Note that it is possible to include thumbnails in formats
other than JPEG although that is not common. The command finds thumbnails that are encoded in
either the JFXX or EXIF segments of the JPEG information. If both are present the EXIF thumbnail
will take precedence. Throws an error if file is not a JPEG image.
set fh [open thumbnail.jpg w+]
fconfigure $fh -translation binary -encoding binary
puts -nonewline $fh [::jpeg::getThumbnail photo.jpg]
close $fh
::jpeg::getExiffile ?section?
section must be one of main or thumbnail. The default is main. Returns a dictionary containing
the EXIF information for the specified section. For example:
set exif {
Make Canon
Model {Canon DIGITAL IXUS}
DateTime {2001:06:09 15:17:32}
}
Throws an error if file is not a JPEG image.
::jpeg::getExifFromChannelchannel ?section?
This command is as per ::jpeg::getExif except that it uses a previously opened channel. channel
should be a seekable channel and section is as described in the documentation of ::jpeg::getExif.
Note: The jpeg parser expects that the start of the channel is the start of the image data. If
working with an image embedded in a container file format it may be necessary to read the jpeg
data into a temporary container: either a temporary file or a memory channel.
Attention: It is the resonsibility of the caller to close the channel after its use.
::jpeg::formatExifkeys
Takes a list of key-value pairs as returned by getExif and formats many of the values into a more
human readable form. As few as one key-value may be passed in, the entire exif is not required.
foreach {key val} [::jpeg::formatExif [::jpeg::getExif photo.jpg]] {
puts "$key: $val"
}
array set exif [::jpeg::getExif photo.jpg]
puts "max f-stop: [::jpeg::formatExif [list MaxAperture $exif(MaxAperture)]]
::jpeg::exifKeys
Returns a list of the EXIF keys which are currently understood. There may be keys present in
getExif data that are not understood. Those keys will appear in a 4 digit hexadecimal format.
::jpeg::removeExiffile
Removes the Exif data segment from the specified file and replaces it with a standard JFIF
segment. Throws an error if file is not a JPEG image.
::jpeg::stripJPEGfile
Removes all metadata from the JPEG file leaving only the image. This includes comments, EXIF
segments, JFXX segments, and application specific segments. Throws an error if file is not a JPEG
image.
::jpeg::getCommentsfile
Returns a list containing all the JPEG comments found in the file. Throws an error if file is not
a valid JPEG image.
::jpeg::addCommentfiletext...
Adds one or more plain text comments to the JPEG image in file. Throws an error if file is not a
valid JPEG image.
::jpeg::removeCommentsfile
Removes all comments from the file specified. Throws an error if file is not a valid JPEG image.
::jpeg::replaceCommentfiletext
Replaces the first comment in the file with the new text. This is merely a shortcut for
::jpeg::removeComments and ::jpeg::addComment Throws an error if file is not a valid JPEG image.
::jpeg::debugfile
Prints everything we know about the given file in a nice format.
::jpeg::markerschannel
This is an internal helper command, we document it for use by advanced users of the package. The
argument channel is an open file handle positioned at the start of the first marker (usually 2
bytes). The command returns a list with one element for each JFIF marker found in the file. Each
element consists of a list of the marker name, its offset in the file, and its length. The offset
points to the beginning of the sections data, not the marker itself. The length is the length of
the data from the offset listed to the start of the next marker.