1jpeg(n) JPEG image manipulation jpeg(n)
2
3
4
5______________________________________________________________________________
6
8 jpeg - JPEG querying and manipulation of meta data
9
11 package require Tcl 8.2
12
13 package require jpeg ?0.3?
14
15 ::jpeg::isJPEG file
16
17 ::jpeg::imageInfo file
18
19 ::jpeg::dimensions file
20
21 ::jpeg::getThumbnail file
22
23 ::jpeg::getExif file ?section?
24
25 ::jpeg::formatExif keys
26
27 ::jpeg::exifKeys
28
29 ::jpeg::removeExif file
30
31 ::jpeg::stripJPEG file
32
33 ::jpeg::getComments file
34
35 ::jpeg::addComment file text...
36
37 ::jpeg::removeComments file
38
39 ::jpeg::replaceComment file text
40
41 ::jpeg::debug file
42
43 ::jpeg::markers channel
44
45_________________________________________________________________
46
48 This package provides commands to query and modify JPEG images. JPEG
49 stands for Joint Photography Experts Group and is a standard for the
50 lossy compression of photographical images. It is specified at
51 LINK_HERE.
52
54 ::jpeg::isJPEG file
55 Returns a boolean value indicating if file is a JPEG image.
56
57 ::jpeg::imageInfo file
58 Returns a dictionary with keys version, units, xdensity, yden‐
59 sity, xthumb, and ythumb. The values are the associated proper‐
60 ties of the JPEG image in file. Throws an error if file is not
61 a JPEG image.
62
63 ::jpeg::dimensions file
64 Returns the dimensions of the JPEG file as a list of the hori‐
65 zontal and vertical pixel count. Throws an error if file is not
66 a JPEG image.
67
68 ::jpeg::getThumbnail file
69 This procedure will return the binary thumbnail image data, if a
70 JPEG thumbnail is included in file, and the empty string other‐
71 wise. Note that it is possible to include thumbnails in formats
72 other than JPEG although that is not common. The command finds
73 thumbnails that are encoded in either the JFXX or EXIF segments
74 of the JPEG information. If both are present the EXIF thumbnail
75 will take precedence. Throws an error if file is not a JPEG
76 image.
77
78 set fh [open thumbnail.jpg w+]
79 puts -nonewline $fh [::jpeg::getThumbnail photo.jpg]
80 close $fh
81
82
83 ::jpeg::getExif file ?section?
84 section must be one of main or thumbnail. The default is main.
85 Returns a dictionary containing the EXIF information for the
86 specified section. For example:
87
88
89 set exif {
90 Make Canon
91 Model {Canon DIGITAL IXUS}
92 DateTime {2001:06:09 15:17:32}
93 }
94
95 Throws an error if file is not a JPEG image.
96
97 ::jpeg::formatExif keys
98 Takes a list of key-value pairs as returned by getExif and for‐
99 mats many of the values into a more human readable form. As few
100 as one key-value may be passed in, the entire exif is not
101 required.
102
103 foreach {key val} [::jpeg::formatExif [::jpeg::getExif photo.jpg]] {
104 puts "$key: $val"
105 }
106
107
108
109 array set exif [::jpeg::getExif photo.jpg]
110 puts "max f-stop: [::jpeg::formatExif [list MaxAperture $exif(MaxAperture)]]
111
112
113 ::jpeg::exifKeys
114 Returns a list of the EXIF keys which are currently understood.
115 There may be keys present in getExif data that are not under‐
116 stood. Those keys will appear in a 4 digit hexadecimal format.
117
118 ::jpeg::removeExif file
119 Removes the Exif data segment from the specified file and
120 replaces it with a standard JFIF segment. Throws an error if
121 file is not a JPEG image.
122
123 ::jpeg::stripJPEG file
124 Removes all metadata from the JPEG file leaving only the image.
125 This includes comments, EXIF segments, JFXX segments, and appli‐
126 cation specific segments. Throws an error if file is not a JPEG
127 image.
128
129 ::jpeg::getComments file
130 Returns a list containing all the JPEG comments found in the
131 file. Throws an error if file is not a valid JPEG image.
132
133 ::jpeg::addComment file text...
134 Adds one or more plain text comments to the JPEG image in file.
135 Throws an error if file is not a valid JPEG image.
136
137 ::jpeg::removeComments file
138 Removes all comments from the file specified. Throws an error
139 if file is not a valid JPEG image.
140
141 ::jpeg::replaceComment file text
142 Replaces the first comment in the file with the new text. This
143 is merely a shortcut for ::jpeg::removeComments and ::jpeg::add‐
144 Comment Throws an error if file is not a valid JPEG image.
145
146 ::jpeg::debug file
147 Prints everything we know about the given file in a nice format.
148
149 ::jpeg::markers channel
150 This is an internal helper command, we document it for use by
151 advanced users of the package. The argument channel is an open
152 file handle positioned at the start of the first marker (usually
153 2 bytes). The command returns a list with one element for each
154 JFIF marker found in the file. Each element consists of a list
155 of the marker name, its offset in the file, and its length. The
156 offset points to the beginning of the sections data, not the
157 marker itself. The length is the length of the data from the
158 offset listed to the start of the next marker.
159
161 can only work with files cant write exif data gps exif data not parsed
162 makernote data not yet implemented
163
165 comment, exif, image, jfif, jpeg, thumbnail
166
168 Copyright (c) 2004, Code: Aaron Faupell <afaupell@users.sourceforge.net>
169 Copyright (c) 2004, Doc: Andreas Kupries <andreas_kupries@users.sourceforge.net>
170
171
172
173
174jpeg 0.3 jpeg(n)