1jpeg(n)                     JPEG image manipulation                    jpeg(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       jpeg - JPEG querying and manipulation of meta data
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require jpeg  ?0.5?
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::getExifFromChannel channel ?section?
26
27       ::jpeg::formatExif keys
28
29       ::jpeg::exifKeys
30
31       ::jpeg::removeExif file
32
33       ::jpeg::stripJPEG file
34
35       ::jpeg::getComments file
36
37       ::jpeg::addComment file text...
38
39       ::jpeg::removeComments file
40
41       ::jpeg::replaceComment file text
42
43       ::jpeg::debug file
44
45       ::jpeg::markers channel
46
47______________________________________________________________________________
48

DESCRIPTION

50       This  package  provides  commands to query and modify JPEG images. JPEG
51       stands for Joint Photography Experts Group and is a  standard  for  the
52       lossy   compression  of  photographical  images.  It  is  specified  at
53       LINK_HERE.
54

COMMANDS

56       ::jpeg::isJPEG file
57              Returns a boolean value indicating if file is a JPEG image.
58
59       ::jpeg::imageInfo file
60              Returns a dictionary with keys version, units,  xdensity,  yden‐
61              sity,  xthumb, and ythumb. The values are the associated proper‐
62              ties of the JPEG image in file.  Throws an error if file is  not
63              a JPEG image.
64
65       ::jpeg::dimensions file
66              Returns  the  dimensions of the JPEG file as a list of the hori‐
67              zontal and vertical pixel count.  Throws an error if file is not
68              a JPEG image.
69
70       ::jpeg::getThumbnail file
71              This procedure will return the binary thumbnail image data, if a
72              JPEG thumbnail is included in file, and the empty string  other‐
73              wise.  Note that it is possible to include thumbnails in formats
74              other than JPEG although that is not common. The  command  finds
75              thumbnails  that are encoded in either the JFXX or EXIF segments
76              of the JPEG information. If both are present the EXIF  thumbnail
77              will  take  precedence.   Throws  an error if file is not a JPEG
78              image.
79
80
81                  set fh [open thumbnail.jpg w+]
82                  fconfigure $fh -translation binary -encoding binary
83                  puts -nonewline $fh [::jpeg::getThumbnail photo.jpg]
84                  close $fh
85
86
87       ::jpeg::getExif file ?section?
88              section must be one of main or thumbnail.  The default is  main.
89              Returns  a  dictionary  containing  the EXIF information for the
90              specified section.  For example:
91
92
93
94                  set exif {
95                Make     Canon
96                Model    {Canon DIGITAL IXUS}
97                DateTime {2001:06:09 15:17:32}
98                  }
99
100
101              Throws an error if file is not a JPEG image.
102
103       ::jpeg::getExifFromChannel channel ?section?
104              This command is as per ::jpeg::getExif except  that  it  uses  a
105              previously opened channel.  channel should be a seekable channel
106              and  section  is  as   described   in   the   documentation   of
107              ::jpeg::getExif.
108
109              Note:  The  jpeg parser expects that the start of the channel is
110              the start of the image data. If working with an  image  embedded
111              in  a container file format it may be necessary to read the jpeg
112              data into a temporary container: either a temporary  file  or  a
113              memory channel.
114
115              Attention:  It  is  the resonsibility of the caller to close the
116              channel after its use.
117
118       ::jpeg::formatExif keys
119              Takes a list of key-value pairs as returned by getExif and  for‐
120              mats  many of the values into a more human readable form. As few
121              as one key-value may be  passed  in,  the  entire  exif  is  not
122              required.
123
124
125                  foreach {key val} [::jpeg::formatExif [::jpeg::getExif photo.jpg]] {
126                      puts "$key: $val"
127                  }
128
129
130
131
132                  array set exif [::jpeg::getExif photo.jpg]
133                  puts "max f-stop: [::jpeg::formatExif [list MaxAperture $exif(MaxAperture)]]
134
135
136       ::jpeg::exifKeys
137              Returns  a list of the EXIF keys which are currently understood.
138              There may be keys present in getExif data that  are  not  under‐
139              stood.  Those keys will appear in a 4 digit hexadecimal format.
140
141       ::jpeg::removeExif file
142              Removes  the  Exif  data  segment  from  the  specified file and
143              replaces it with a standard JFIF segment.  Throws  an  error  if
144              file is not a JPEG image.
145
146       ::jpeg::stripJPEG file
147              Removes  all metadata from the JPEG file leaving only the image.
148              This includes comments, EXIF segments, JFXX segments, and appli‐
149              cation specific segments.  Throws an error if file is not a JPEG
150              image.
151
152       ::jpeg::getComments file
153              Returns a list containing all the JPEG  comments  found  in  the
154              file.  Throws an error if file is not a valid JPEG image.
155
156       ::jpeg::addComment file text...
157              Adds  one or more plain text comments to the JPEG image in file.
158              Throws an error if file is not a valid JPEG image.
159
160       ::jpeg::removeComments file
161              Removes all comments from the file specified.  Throws  an  error
162              if file is not a valid JPEG image.
163
164       ::jpeg::replaceComment file text
165              Replaces  the first comment in the file with the new text.  This
166              is merely a shortcut for ::jpeg::removeComments and ::jpeg::add‐
167              Comment Throws an error if file is not a valid JPEG image.
168
169       ::jpeg::debug file
170              Prints everything we know about the given file in a nice format.
171
172       ::jpeg::markers channel
173              This  is  an  internal helper command, we document it for use by
174              advanced users of the package. The argument channel is  an  open
175              file handle positioned at the start of the first marker (usually
176              2 bytes). The command returns a list with one element  for  each
177              JFIF  marker  found in the file. Each element consists of a list
178              of the marker name, its offset in the file, and its length.  The
179              offset  points  to  the  beginning of the sections data, not the
180              marker itself.  The length is the length of the  data  from  the
181              offset listed to the start of the next marker.
182

LIMITATIONS

184       can  only work with files cant write exif data gps exif data not parsed
185       makernote data not yet implemented
186

BUGS, IDEAS, FEEDBACK

188       This document, and the package it describes, will  undoubtedly  contain
189       bugs  and  other  problems.  Please report such in the category jpeg of
190       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
191       also  report any ideas for enhancements you may have for either package
192       and/or documentation.
193
194       When proposing code changes, please provide unified diffs, i.e the out‐
195       put of diff -u.
196
197       Note  further  that  attachments  are  strongly  preferred over inlined
198       patches. Attachments can be made by going  to  the  Edit  form  of  the
199       ticket  immediately  after  its  creation, and then using the left-most
200       button in the secondary navigation bar.
201

KEYWORDS

203       comment, exif, image, jfif, jpeg, thumbnail
204

CATEGORY

206       File formats
207
209       Copyright (c) 2004-2005, Code: Aaron Faupell <afaupell@users.sourceforge.net>
210       Copyright (c) 2007, Code:  Andreas Kupries <andreas_kupries@users.sourceforge.net>
211       Copyright (c) 2004-2009, Doc:  Andreas Kupries <andreas_kupries@users.sourceforge.net>
212       Copyright (c) 2011, Code: Pat Thoyts <patthoyts@users.sourceforge.net>
213
214
215
216
217tcllib                                0.5                              jpeg(n)
Impressum