rjhead 0.2.88
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/ext/changes.txt +351 -0
- data/ext/exif.c +1629 -0
- data/ext/extconf.rb +0 -0
- data/ext/gpsinfo.c +217 -0
- data/ext/iptc.c +205 -0
- data/ext/jhead.1 +409 -0
- data/ext/jhead.c +1697 -0
- data/ext/jhead.h +251 -0
- data/ext/jhead.spec +149 -0
- data/ext/jpgfile.c +738 -0
- data/ext/make.bat +1 -0
- data/ext/makefile +23 -0
- data/ext/makefile-win32 +27 -0
- data/ext/makernote.c +184 -0
- data/ext/myglob.c +305 -0
- data/ext/paths.c +140 -0
- data/ext/readme.txt +60 -0
- data/ext/usage.html +469 -0
- data/lib/rjhead.rb +0 -0
- data/rjhead.gemspec +73 -0
- data/setup.rake +1 -0
- data/test/rjhead_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +94 -0
data/ext/paths.c
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
//--------------------------------------------------------------------------------
|
2
|
+
// Module to do path manipulation for file moving of jhead.
|
3
|
+
//
|
4
|
+
// Matthias Wandel Feb 2 2009
|
5
|
+
//--------------------------------------------------------------------------------
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <stdlib.h>
|
8
|
+
#include <string.h>
|
9
|
+
#include <errno.h>
|
10
|
+
#include <ctype.h>
|
11
|
+
#include <ctype.h>
|
12
|
+
#include <sys/stat.h>
|
13
|
+
#ifdef _WIN32
|
14
|
+
#include <direct.h> // for mkdir under windows.
|
15
|
+
#define mkdir(dir,mode) mkdir(dir)
|
16
|
+
#define S_ISDIR(a) (a & _S_IFDIR)
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#include "jhead.h"
|
20
|
+
|
21
|
+
//--------------------------------------------------------------------------------
|
22
|
+
// Ensure that a path exists
|
23
|
+
//--------------------------------------------------------------------------------
|
24
|
+
int EnsurePathExists(const char * FileName)
|
25
|
+
{
|
26
|
+
char NewPath[PATH_MAX*2];
|
27
|
+
int a;
|
28
|
+
int LastSlash = 0;
|
29
|
+
|
30
|
+
//printf("\nEnsure exists:%s\n",FileName);
|
31
|
+
|
32
|
+
// Extract the path component of the file name.
|
33
|
+
strcpy(NewPath, FileName);
|
34
|
+
a = strlen(NewPath);
|
35
|
+
for (;;){
|
36
|
+
a--;
|
37
|
+
if (a == 0){
|
38
|
+
NewPath[0] = 0;
|
39
|
+
break;
|
40
|
+
}
|
41
|
+
if (NewPath[a] == SLASH){
|
42
|
+
struct stat dummy;
|
43
|
+
NewPath[a] = 0;
|
44
|
+
if (stat(NewPath, &dummy) == 0){
|
45
|
+
if (S_ISDIR(dummy.st_mode)){
|
46
|
+
// Break out of loop, and go forward along path making
|
47
|
+
// the directories.
|
48
|
+
if (LastSlash == 0){
|
49
|
+
// Full path exists. No need to create any directories.
|
50
|
+
return 1;
|
51
|
+
}
|
52
|
+
break;
|
53
|
+
}else{
|
54
|
+
// Its a file.
|
55
|
+
fprintf(stderr,"Can't create path '%s' due to file conflict\n",NewPath);
|
56
|
+
return 0;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
if (LastSlash == 0) LastSlash = a;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
// Now work forward.
|
64
|
+
//printf("Existing First dir: '%s' a = %d\n",NewPath,a);
|
65
|
+
|
66
|
+
for(;FileName[a];a++){
|
67
|
+
if (FileName[a] == SLASH || a == 0){
|
68
|
+
if (a == LastSlash) break;
|
69
|
+
NewPath[a] = FileName[a];
|
70
|
+
//printf("make dir '%s'\n",NewPath);
|
71
|
+
#ifdef _WIN32
|
72
|
+
if (NewPath[1] == ':' && strlen(NewPath) == 2) continue;
|
73
|
+
#endif
|
74
|
+
if (mkdir(NewPath,0777)){
|
75
|
+
fprintf(stderr,"Could not create directory '%s'\n",NewPath);
|
76
|
+
// Failed to create directory.
|
77
|
+
return 0;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
return 1;
|
82
|
+
}
|
83
|
+
|
84
|
+
//--------------------------------------------------------------------------------
|
85
|
+
// Make a new path out of a base path, and a filename.
|
86
|
+
// Basepath is the base path, and FilePath is a filename, or path + filename.
|
87
|
+
//--------------------------------------------------------------------------------
|
88
|
+
void CatPath(char * BasePath, const char * FilePath)
|
89
|
+
{
|
90
|
+
int l;
|
91
|
+
l = strlen(BasePath);
|
92
|
+
|
93
|
+
if (FilePath[1] == ':'){
|
94
|
+
// Its a windows absolute path.
|
95
|
+
l = 0;
|
96
|
+
}
|
97
|
+
|
98
|
+
if (FilePath[0] == SLASH || FilePath[0] == '.' || l == 0){
|
99
|
+
// Its an absolute path, or there was no base path.
|
100
|
+
strcpy(BasePath, FilePath);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (BasePath[l-1] != SLASH){
|
105
|
+
BasePath[l++] = SLASH;
|
106
|
+
BasePath[l] = 0;
|
107
|
+
}
|
108
|
+
|
109
|
+
strcat(BasePath, FilePath);
|
110
|
+
|
111
|
+
// Note that the combined path may contains things like "foo/../bar". We assume
|
112
|
+
// that the filesystem will take care of these.
|
113
|
+
}
|
114
|
+
|
115
|
+
/*
|
116
|
+
|
117
|
+
char Path1[] = "ztest\\cdir\\foo.jpg";
|
118
|
+
char Path2[] = "zxtest\\cdir\\foo.jpg";
|
119
|
+
char Path3[] = "\\tzest\\cdir\\foo.jpg";
|
120
|
+
|
121
|
+
char BasePath[100];
|
122
|
+
|
123
|
+
main()
|
124
|
+
{
|
125
|
+
EnsurePathExists(Path1);
|
126
|
+
EnsurePathExists(Path2);
|
127
|
+
EnsurePathExists(Path3);
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
CatPath(BasePath, "hello.txt");
|
133
|
+
CatPath(BasePath, "world\\hello.txt");
|
134
|
+
CatPath(BasePath, "\\hello.txt");
|
135
|
+
CatPath(BasePath, "c:\\hello.txt");
|
136
|
+
CatPath(BasePath, "c:\\world\\hello.txt");
|
137
|
+
CatPath(BasePath, "c:\\abresl\\hello.txt");
|
138
|
+
|
139
|
+
}
|
140
|
+
*/
|
data/ext/readme.txt
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
Some notes:
|
3
|
+
|
4
|
+
When I first wrote Jhead back in 1999, there wasn't much software around
|
5
|
+
for looking inside Exif headers, so I wrote jhead for that task. Since
|
6
|
+
then, a lot of much more sophisticated programs for looking inside Exif
|
7
|
+
headers have been written, many with GUIs, and features that Jhead lacks.
|
8
|
+
|
9
|
+
Seeing that Jhead does everything I need it to do, My goal is not to have
|
10
|
+
every feature imaginable. Rather, I want Jhead to be a small, simple,
|
11
|
+
easy to understand program. My goal is that if you need to understand
|
12
|
+
Exif internals, or add Exif capability to your program, Jhead is the
|
13
|
+
place to cut and paste code from.
|
14
|
+
|
15
|
+
As a result, Jhead may not have your pet feature. Feel free to add your
|
16
|
+
pet feature to Jhead - its meant to be hacked. If you send me your
|
17
|
+
changes, I might integrate it, but only if its simple.
|
18
|
+
|
19
|
+
If you find that it dies on a certain jpeg file, send it to me, and I
|
20
|
+
will look at it.
|
21
|
+
|
22
|
+
|
23
|
+
Compiling:
|
24
|
+
|
25
|
+
Windows:
|
26
|
+
|
27
|
+
Make sure visual C is on your path (I use version 6 from 1998,
|
28
|
+
but it shouldn't matter much).
|
29
|
+
Run the batch file make.bat
|
30
|
+
|
31
|
+
Linux & Unices:
|
32
|
+
|
33
|
+
type 'make'.
|
34
|
+
|
35
|
+
Portability:
|
36
|
+
|
37
|
+
Although I have never done so myself, people tell me it compiles
|
38
|
+
under platforms as diverse as such as Mac OS-X, or NetBSD on Mac68k.
|
39
|
+
Jhead doesn't care about the endian-ness of your CPU, and should not
|
40
|
+
have problems with processors that do not handle unaligned data,
|
41
|
+
such as ARM or Alpha. The main portability problem is the use
|
42
|
+
of C++ style '//' comments. This is intentional, and won't change.
|
43
|
+
|
44
|
+
Jhead has also made its way into various Linux distributions and ports
|
45
|
+
trees, so you might already have it on your system without knowing.
|
46
|
+
Note that I am a windows weenie myself.
|
47
|
+
|
48
|
+
License:
|
49
|
+
|
50
|
+
Jhead is public domain software - that is, you can do whatever you want
|
51
|
+
with it, and include it software that is licensed under the GNU or the
|
52
|
+
BSD license, or whatever other licence you chose, including proprietary
|
53
|
+
closed source licenses. Although not part of the license, I do expect
|
54
|
+
common courtesy, please.
|
55
|
+
|
56
|
+
If you do integrate the code into some software of yours, I'd appreciate
|
57
|
+
knowing about it though.
|
58
|
+
|
59
|
+
Matthias Wandel
|
60
|
+
|
data/ext/usage.html
ADDED
@@ -0,0 +1,469 @@
|
|
1
|
+
<html>
|
2
|
+
<span style="font-family: helvetica,arial,sans-serif;">
|
3
|
+
|
4
|
+
<h3>Jhead is a command line driven program for manipulating the non-image parts of Exif flavour
|
5
|
+
JPEG files that most digital cameras produce.</h3><p>
|
6
|
+
|
7
|
+
Windows / Mac users: Jhead has <b>no Graphical User Interface</b>. Clicking on it with the mouse from Windows
|
8
|
+
or Mac OS-X won't do anything for you - you have to <b>use it from the Command prompt</b>
|
9
|
+
|
10
|
+
|
11
|
+
<h3>Jhead v2.88 program Features</h3>
|
12
|
+
<ul>
|
13
|
+
<li>Extracting camera settings from Exif image files
|
14
|
+
<li>Able to set and/or adjust the Exif time field
|
15
|
+
<li>Manipulation (extract, replace, regenerate) of Exif integral thumbnails
|
16
|
+
<li>Transplant Exif image header from one JPEG to another
|
17
|
+
<li>Edit JPEG comment fields
|
18
|
+
<li>Automatically rotate images upright (using jpegtran) according to "orientation" tag.
|
19
|
+
<li>Manage running programs on large batches of Jpegs and restoring Exif header
|
20
|
+
information afterwards.
|
21
|
+
<li>Display embedded GPS info (if present)
|
22
|
+
</ul>
|
23
|
+
|
24
|
+
|
25
|
+
<h3>General metadata options</h3>
|
26
|
+
<table cellpadding=5>
|
27
|
+
|
28
|
+
<tr valign=top><td><b>-te <name>
|
29
|
+
<td>
|
30
|
+
Transplant Exif header from image <name> into specified image. This option is
|
31
|
+
useful if you like to edit the photos but still want the Exif header on your photos.
|
32
|
+
As most photo editing programs will wipe out the Exif header, this option can be used
|
33
|
+
to re-transplant them back in after editing the photos.
|
34
|
+
<br>
|
35
|
+
This feature has an interesting 'relative path' option for specifying the thumbnail name.
|
36
|
+
Whenever the <name> contains the characters '&i', jhead will substitute the original
|
37
|
+
filename for this name. This allows creating a 'relative name' when doing a whole
|
38
|
+
batch of files. For example, the incantation:
|
39
|
+
<ul>jhead -te "originals\&i" *.jpg</ul>
|
40
|
+
would transfer the Exif header for each .jpg file in the originals directory by the same name,
|
41
|
+
Both Win32 and most UNIX shells treat the '&' character in a special way, so you have to
|
42
|
+
put quotes around that command line option for the '&' to even be passed to the program.
|
43
|
+
|
44
|
+
|
45
|
+
<tr valign=top><td><b>-dc
|
46
|
+
<td>Delete comment field from the JPEG header. Note that the comment
|
47
|
+
is not part of the Exif header.
|
48
|
+
|
49
|
+
<tr valign=top><td><b>-de
|
50
|
+
<td>Delete the Exif header entirely. This leaves other sections (IPTC, XMP, comment) intact
|
51
|
+
|
52
|
+
<tr valign=top><td><b>-di
|
53
|
+
<td>Delete IPTC section (if present). Leaves other sections intact.
|
54
|
+
|
55
|
+
<tr valign=top><td><b>-dx
|
56
|
+
<td>Delete XMP section (if present). Leaves other sections intact.
|
57
|
+
|
58
|
+
<tr valign=top><td><b>-du
|
59
|
+
<td>Delete any sections that jhead doesn't know about. Leaves Exif, XMP, IPTC and comment
|
60
|
+
sections intact.
|
61
|
+
|
62
|
+
<tr valign=top><td><b>-purejpg
|
63
|
+
<td>Delete all JPEG sections that aren't necessary for rendering the image. Strips any
|
64
|
+
metadata that various applications may have left in the image. A combination of
|
65
|
+
the -de -dc and -du options.
|
66
|
+
|
67
|
+
<tr valign=top><td><b>-mkexif
|
68
|
+
<td>Creates minimal Exif header. Exif header contains date/time, and empty thumbnail
|
69
|
+
fields only. Date/time set to file time by default.
|
70
|
+
use with -rgt option if you want the Exif header to contain a thumbnail.
|
71
|
+
Note that Exif header creation is very limited at this time, and no other fields
|
72
|
+
can be added to the Exif header this way.
|
73
|
+
|
74
|
+
<tr valign=top><td><b>-ce
|
75
|
+
<td>Edit the JPEG header comment field (note, this comment field is outside the Exif structure
|
76
|
+
and can be part of Exif and non Exif style JPEG images).
|
77
|
+
<br>
|
78
|
+
A temporary file containing the comment is created and a text editor is launched to edit
|
79
|
+
the file. The editor is specified in the EDITOR environment variable. If none is specified
|
80
|
+
notepad or vi are used under Windows and UNIX respectively. After the editor exits,
|
81
|
+
the data is transferred back into the image, and the temporary file deleted.
|
82
|
+
|
83
|
+
<tr valign=top><td><b>-cs <name>
|
84
|
+
<td>Save comment section to a file
|
85
|
+
|
86
|
+
<tr valign=top><td><b>-ci <name>
|
87
|
+
<td>Replace comment with text from file.
|
88
|
+
|
89
|
+
<tr valign=top><td><b>-cl <comment>
|
90
|
+
<td>Replace comment with comment from command line.
|
91
|
+
</table>
|
92
|
+
|
93
|
+
|
94
|
+
<h3>Date / Time manipulation options</h3>
|
95
|
+
<table cellpadding=5>
|
96
|
+
|
97
|
+
<tr valign=top><td><b>-ft
|
98
|
+
<td>Sets the file's system time stamp to what is stored in the Exif header.
|
99
|
+
|
100
|
+
<tr valign=top><td><b>-dsft
|
101
|
+
<td>Sets the Exif timestamp to the file's timestamp. Requires an Exif header to pre-exist.
|
102
|
+
Use -mkexif option to create one if needed.
|
103
|
+
|
104
|
+
<tr valign=top><td><b>-n[<fmt-string>]
|
105
|
+
<td>This option causes files to be renamed and/or moved according to the Exif header "DateTimeOriginal" field.
|
106
|
+
If the file is not an Exif file, or the DateTimeOriginal does not contain a valid value,
|
107
|
+
the file date is used.
|
108
|
+
Renaming is by default restricted to files whose names consist largely of digits.
|
109
|
+
This effectively restricts renaming to files that have not already been manually renamed, as
|
110
|
+
the default sequential names from digital cameras consist largely of digits.
|
111
|
+
Use the -nf option to force renaming of all files.
|
112
|
+
<p>
|
113
|
+
If the name includes '/' or '\' (under windows), this is interpreted as a new path for
|
114
|
+
the file. If the new path does not exist, the path will be created.
|
115
|
+
<p>
|
116
|
+
If the [fmt-string] is omitted, the file will be renamed to MMDD-HHMMSS.
|
117
|
+
<br>
|
118
|
+
If a [fmt-string] is provided, the fmt-string will be passed to the
|
119
|
+
strftime function for formatting. In addition, if the format string contains '%f', this will
|
120
|
+
substitute the original name of the file (minus extension).
|
121
|
+
<br>
|
122
|
+
A sequence number may also be included by including '%i' in the format string. Leading
|
123
|
+
zeros can be specified. '%03i' for example will pad the numbers to '001', '002'...
|
124
|
+
this works just like printf in C, but with '%i' instead of '%d'.
|
125
|
+
<br>
|
126
|
+
If the target name already exists, the name will be appended with "a", "b", "c", etc,
|
127
|
+
unless the name ends with a letter, in which case it will be appended with "0", "1", "2", etc.
|
128
|
+
<br>
|
129
|
+
This feature is especially useful if more than one digital camera was used to take pictures
|
130
|
+
of an event. By renaming them to a scheme according to date, they will automatically
|
131
|
+
appear in order of taking when viewed with some sort of viewer like Xnview or AcdSee, and
|
132
|
+
sorted by name. Or you could use the -ft option and view the images sorted by date.
|
133
|
+
Typically, one of the carera's date will be set not quite right, in which case you may have
|
134
|
+
to use the -ta or -da options on those files first.
|
135
|
+
<p>
|
136
|
+
<b>Some of the more useful arguments for strftime are:</b>
|
137
|
+
|
138
|
+
<table>
|
139
|
+
<tr><td>%d   </td><td>Day of month as decimal number (01 � 31)
|
140
|
+
<tr><td>%H</td><td>Hour in 24-hour format (00 � 23)
|
141
|
+
<tr><td>%j</td><td>Day of year as decimal number (001 � 366)
|
142
|
+
<tr><td>%m</td><td>Month as decimal number (01 � 12)
|
143
|
+
<tr><td>%M</td><td>Minute as decimal number (00 � 59)
|
144
|
+
<tr><td>%S</td><td>Second as decimal number (00 � 59)
|
145
|
+
<tr><td>%U</td><td>Week of year as decimal number, with Sunday as first day of week (00 � 53)
|
146
|
+
<tr><td>%w</td><td>Weekday as decimal number (0 � 6; Sunday is 0)
|
147
|
+
<tr><td>%y</td><td>Year without century, as decimal number (00 � 99)
|
148
|
+
<tr><td>%Y</td><td>Year with century, as decimal number
|
149
|
+
</table>
|
150
|
+
<p>
|
151
|
+
Example:<br>
|
152
|
+
    jhead -n%Y%m%d-%H%M%S *.jpg<p>
|
153
|
+
This will rename files matched by *.jpg according to YYYYMMDD-HHMMSS
|
154
|
+
<p>
|
155
|
+
Note to Windows batch file users: '%' is used to deliminate macros in Windows batch files. You must
|
156
|
+
use %% to get one % passed to the program. So from a batch file, you would have to write "jhead -n%%Y%%m%%d-%%H%%M%%S *.jpg"
|
157
|
+
<p>
|
158
|
+
For a full listing of strftime arguments, look up the strftime function. Note that some arguments
|
159
|
+
to the strftime function (not listed here) produce strings with characters such as '/' and ':' that
|
160
|
+
may not be valid as part of a filename on various systems.
|
161
|
+
|
162
|
+
<tr valign=top><td><b>-nf
|
163
|
+
<td>Same as '-n' but renames files regardless of original file name.
|
164
|
+
|
165
|
+
<tr valign=top><td><b>-a
|
166
|
+
<td>(Windows only option). Rename files with the same name but different extension as well.
|
167
|
+
This is useful for renaming .AVI files based on Exif file in .THM, or to rename sound annotation
|
168
|
+
files or raw files with jpeg files. Use together with '-n' option.
|
169
|
+
|
170
|
+
<tr valign=top><td><b>-ta<timediff>
|
171
|
+
<td>Adjust time stored in the Exif header by h:mm backwards or forwards. Useful when having
|
172
|
+
taken pictures with the wrong time set on the camera, such as after travelling across
|
173
|
+
time zones, or when daylight savings time has changed.
|
174
|
+
This option uses the time from the "DateTimeOriginal" (tag 0x9003) field, but sets
|
175
|
+
all the time fields in the Exif header to the new value. Version 2.0 and earlier only
|
176
|
+
modified the "DateTimeOriginal" (tag 0x9003) field, but too many people thought
|
177
|
+
that that was a bug.
|
178
|
+
|
179
|
+
Examples:<br>
|
180
|
+
Adjust time one hour forward (you would use this after you forgot to set daylight savings
|
181
|
+
time on the digicam)<br>
|
182
|
+
<ul>jhead -ta+1:00 *.jpg</ul>
|
183
|
+
Adjust time back by 23 seconds (you would use this to get the timestamps from two digicams
|
184
|
+
in sync after you found that they didn't quite align)
|
185
|
+
<ul>jhead -ta-0:00:23 *.jpg</ul>
|
186
|
+
Adjust time forward by 2 days and 1 hour (49 hours)
|
187
|
+
<ul>jhead -ta+49 *.jpg</ul>
|
188
|
+
|
189
|
+
<tr valign=top><td><b>-da<date>-<date>
|
190
|
+
<td>Works like -ta, but for specifying large date offsets, to be used when fixing dates from
|
191
|
+
cameras where the date was set incorrectly, such as having date and time reset by battery
|
192
|
+
removal on some cameras. This feature is best for adjusting dates on pictures taken
|
193
|
+
over a large range of dates. For pictures all taken the same date, the "-ds" option
|
194
|
+
is often easier to use.
|
195
|
+
<p>
|
196
|
+
Because different months and years have different numbers of days in them, a simple offset
|
197
|
+
for months, days, years would lead to unexpected results at times. The time offset is
|
198
|
+
thus specified as a difference between two dates, so that jhead can figure out exactly
|
199
|
+
how many days the timestamp needs to be adjusted by, including leap years and daylight
|
200
|
+
savings time changes.
|
201
|
+
The dates are specified as yyyy:mm:dd. For sub-day adjustments, a time of day can also
|
202
|
+
be included, by specifying yyyy:nn:dd/hh:mm or yyyy:mm:dd/hh:mm:ss
|
203
|
+
<p>
|
204
|
+
Examples:<br>
|
205
|
+
Year on camera was set to 2005 instead of 2004 for pictures taken in April
|
206
|
+
<ul>jhead -da2005:03:01-2004:03:01</ul>
|
207
|
+
Default camera date is 2002:01:01, and date was reset on 2005:05:29 at 11:21 am
|
208
|
+
<ul>jhead -da2005:05:29/11:21-2002:01:01</ul>
|
209
|
+
|
210
|
+
<tr valign=top><td><b>-ts<date-time>
|
211
|
+
<td>Sets the date and time stored in the Exif header to what is specified on the command line.
|
212
|
+
This option changes all the date fields in the Exif header.
|
213
|
+
Time must be specified as:<br>
|
214
|
+
<font face=courier>     yyyy:mm:dd-hh:mm:ss</font><p>
|
215
|
+
|
216
|
+
<tr valign=top><td><b>-ds<date-time>
|
217
|
+
<td>Sets the date stored in the Exif header to what is specified on the command line.
|
218
|
+
Can be used to set date, just year and month, or just year.
|
219
|
+
Date is specified as:<br>
|
220
|
+
<font face=courier>     yyyy:mm:dd, yyyy:mm, or yyyy</font><p>
|
221
|
+
|
222
|
+
</table>
|
223
|
+
<h3>Thumbnail manipulation options</h3>
|
224
|
+
<table cellpadding=5>
|
225
|
+
<tr valign=top><td><b>-dt
|
226
|
+
<td>Delete thumbnails from the Exif header, but leave the
|
227
|
+
interesting parts intact. This option truncates the thumbnail from the Exif header, provided
|
228
|
+
that the thumbnail is the last part of the Exif header (which so far as I know is always the case).
|
229
|
+
Exif headers have a built-in thumbnail, which is typically 240x160 and 10k in size.
|
230
|
+
This thumbnail is used by digital cameras. Windows XP, as well
|
231
|
+
as various photo viewing software may also use this thumbnail if present, but work just fine
|
232
|
+
if it isn't.
|
233
|
+
|
234
|
+
<tr valign=top><td><b>-st <name>
|
235
|
+
<td>Save the built in thumbnail from Jpegs that came from a digital camera. The thumbnail lives
|
236
|
+
inside the Exif header, and is a very low-res JPEG image. Note that making
|
237
|
+
any changes to a photo, except for with some programs, generally wipes out the Exif header
|
238
|
+
and with it the thumbnail.
|
239
|
+
<br>
|
240
|
+
I implemented this option because I kept getting asked about having such an option.
|
241
|
+
I don't consider the
|
242
|
+
built in thumbnails to be all that useful - too low res. However, now you can see for
|
243
|
+
yourself. I always generate my thumbnails using ImageMagick (see end of this page).
|
244
|
+
<br>
|
245
|
+
Like the '-te' option, this feature has the 'relative path' option for specifying the
|
246
|
+
thumbnail name.
|
247
|
+
Whenever the <name> contains the characters '&i', jhead will substitute the original
|
248
|
+
filename for this name. This allows creating a 'relative name' when doing a whole
|
249
|
+
batch of files. For example, the incantation:
|
250
|
+
<ul>jhead -st "thumbnails\&i" *.jpg</ul>
|
251
|
+
would create a thumbnail for each .jpg file in the thumbnails directory by the same name,
|
252
|
+
(provided that the thumbnails directory exists, of course).
|
253
|
+
Both Win32 and most UNIX shells treat the '&' character in a special way, so you have to
|
254
|
+
put quotes around that command line option for the '&' to even be passed to the program.
|
255
|
+
<p>
|
256
|
+
If a '-' is specified for the output file, the thumbnail is sent to stdout. (UNIX build only)
|
257
|
+
|
258
|
+
<tr valign=top><td><b>-rt <name>
|
259
|
+
<td>Replace thumbnails from the Exif header.
|
260
|
+
This only works if the Exif header already contains an Exif header a thumbnail.
|
261
|
+
|
262
|
+
<tr valign=top><td><b>-rgt[size]
|
263
|
+
<td>Regnerate Exif thumbnail.
|
264
|
+
'size' specifies maximum height or width of thumbnail.
|
265
|
+
I added this option because I had a lot of images that I had rotated with various tools that don't
|
266
|
+
update the Exif header. But newer image browsers such as XnView make use of the Exif thumbnail,
|
267
|
+
and so the thumbnails would be different from the image itself. Note that the rotation tag also
|
268
|
+
needed to be cleared (-norot option).
|
269
|
+
<br>
|
270
|
+
Typically, only images that are shot in portrait orientation are afflicted with this. You can use
|
271
|
+
the -orp option to tell jhead to only operate on images that are upright.
|
272
|
+
<p>
|
273
|
+
|
274
|
+
This option relies on 'mogrify' program (from ImageMagick) to regenerate the thumbnail.
|
275
|
+
Linux users often already have this tool pre-installed. Windows users have to go and download it.
|
276
|
+
This option only works if the image already contains a thumbail.
|
277
|
+
</table>
|
278
|
+
|
279
|
+
<h3>Rotation tag manipulation</h3>
|
280
|
+
<table cellpadding=5>
|
281
|
+
<tr valign=top>
|
282
|
+
<td><b>-autorot
|
283
|
+
<td>
|
284
|
+
Using the 'Orientation' tag of the Exif header, rotate the image so that it is upright.
|
285
|
+
The program 'jpegtran' is used to perform the rotation. This program is present in most
|
286
|
+
Linux distributions. For windows, you need to get a copy of it.
|
287
|
+
After rotation, the orientation tag of the Exif header is set to '1' (normal orientation).
|
288
|
+
The Exif thumbnail is also rotated as of Jhead version 2.5. Other fields of the Exif header,
|
289
|
+
including dimensions are untouched, but the JPEG height/width are adjusted.<br>
|
290
|
+
This feature is especially useful with newer digital cameras, which set the orientation
|
291
|
+
field in the Exif header automatically using a built in orientation sensor in the camera.
|
292
|
+
|
293
|
+
<tr valign=top>
|
294
|
+
<td><b>-norot
|
295
|
+
<td>
|
296
|
+
Clears the Exif header rotation tag without altering the image.
|
297
|
+
You may find that your images have rotation tags in them from your camera, but you already
|
298
|
+
rotated them with some lossless tool without clearing the rotation tag.
|
299
|
+
Now your friendly browser rotates the images on you again because the image rotation
|
300
|
+
tag still indicates the image should be rotated. Use this option to fix this problem.
|
301
|
+
You may also want to regenerate the thumbnail using the -rgt option.
|
302
|
+
</table>
|
303
|
+
|
304
|
+
|
305
|
+
<h3>Output verbosity control</h3>
|
306
|
+
<table cellpadding=5>
|
307
|
+
|
308
|
+
|
309
|
+
<tr valign=top><td><b>-h
|
310
|
+
<td>Displays summary of command line options.
|
311
|
+
|
312
|
+
<tr valign=top><td><b>-v
|
313
|
+
<td>Makes the program even more verbose than it already is. Like DOS programs, and unlike
|
314
|
+
UNIX programs, Jhead gives feedback as to what it is doing, even when nothing goes wrong.
|
315
|
+
Windows user that I am, when something doesn't give me feedback for 20 seconds, I assume
|
316
|
+
its crashed.
|
317
|
+
|
318
|
+
<tr valign=top><td><b>-q
|
319
|
+
<td>Makes the progran mot spit out messages on success - more like the "Silence is golden" Unix way. its crashed.
|
320
|
+
|
321
|
+
<tr valign=top><td><b>-V
|
322
|
+
<td>Print version info and compilation date.
|
323
|
+
|
324
|
+
<tr valign=top><td><b>-Exifmap
|
325
|
+
<td>Show a map of the bytes in the Exif header. Useful when analyzing strange Exif headers,
|
326
|
+
not of much use to non software developers.
|
327
|
+
|
328
|
+
<tr valign=top><td><b>-se
|
329
|
+
<td>Suppress error messages relating to corrupt Exif header structure.
|
330
|
+
|
331
|
+
<tr valign=top><td><b>-c
|
332
|
+
<td>Concise output. This causes picture info to be summarized on one line instead of several.
|
333
|
+
Useful for grep-ing through images, as well as importing into spread sheets (data is space
|
334
|
+
delimited with quotes as text qualifier).
|
335
|
+
|
336
|
+
</table>
|
337
|
+
|
338
|
+
|
339
|
+
<h3>File matching and selection</h3>
|
340
|
+
<table cellpadding=5>
|
341
|
+
|
342
|
+
<tr valign=top><td><b>-model
|
343
|
+
<td>Restricts processing of files to those whose camera model, as indicated by the Exif image
|
344
|
+
information, contains the substring specified in the argument after '-model'.
|
345
|
+
For example, the following command will list only images that are from an S100 camera:
|
346
|
+
<p>
|
347
|
+
jhead -model S100 *.jpg<p>
|
348
|
+
<p>
|
349
|
+
I use this option to restrict my JPEG re-compressing to those images that came from my
|
350
|
+
Cannon S100 digicam, (see the -cmd option).
|
351
|
+
|
352
|
+
<tr valign=top>
|
353
|
+
<td><b>-exonly
|
354
|
+
<td>Skip all files that don't have an Exif header. This skips all files that did not
|
355
|
+
come directly from the digital camera, as most photo editing software does not
|
356
|
+
preserve the Exif header when saving pictures.
|
357
|
+
|
358
|
+
<tr valign=top><td><b>-cmd<command>
|
359
|
+
<td>Executes the specified command on each Jepg file to be processed.<p>
|
360
|
+
The Exif section of each file is read before running the command, and re-inserted
|
361
|
+
after the command finishes.
|
362
|
+
<p>
|
363
|
+
This is useful for using jhead's file globbing capability for processing a whole
|
364
|
+
directory tree of files.
|
365
|
+
<p>
|
366
|
+
It's also useful for restoring the exif header after operatiosn that wipe out
|
367
|
+
the Exif metadata. Most programs today however will keep the Exif metadata
|
368
|
+
intact, so this is less important than it used to be.
|
369
|
+
|
370
|
+
<tr valign=top><td><b>-orp -orl
|
371
|
+
<td>Operate only on images with portrait (-orp) or landscape (-orl) aspect ratio.<br>
|
372
|
+
Please note that this is solely based on jpeg width and height values. Some browsers may auto
|
373
|
+
rotate the image on displaying it based on the Exif orientation tag, so that images shot
|
374
|
+
in portrait mode are displayed as portrait. However, the image itself may not be stored in
|
375
|
+
portrait orientation.
|
376
|
+
The -autorot and -norot options are useful for dealing with rotation issues.
|
377
|
+
|
378
|
+
<tr valign=top><td><b>-r
|
379
|
+
<td>The recursive feature of version 1.0 never worked to my satisfaction, and I replaced it
|
380
|
+
with my recursive file globbing code in the Windows version. See below.
|
381
|
+
|
382
|
+
</table>
|
383
|
+
|
384
|
+
<h3>Bugs and Shortcomings</h3>
|
385
|
+
<ul>
|
386
|
+
After jhead runs a program to rotate or resize an image, the image dimensions and thumbnail
|
387
|
+
in the Exif header are not adjusted.
|
388
|
+
<p>
|
389
|
+
Modifying of Exif header data is very limited, as Jhead internally only has a read only
|
390
|
+
implementation of the file system contained in the Exif header. For example, there is no way
|
391
|
+
to replace the thumbnail or edit the Exif comment in the Exif header. There is also no way
|
392
|
+
to create minimal Exif headers.
|
393
|
+
<p>
|
394
|
+
|
395
|
+
Most Canon digital SLR cameras fail to adjust the effective sensor resolution when shooting at less
|
396
|
+
than full resolution, causing jhead to incorrectly miscalculate the sensor width and 35mm equivalent
|
397
|
+
focal length. The same can result from resizing photos with Photoshop, which will manipulate
|
398
|
+
parts of the Exif header.
|
399
|
+
This is often reported as a bug in Jhead, but Jhead can't do much about incorrect data.
|
400
|
+
</ul>
|
401
|
+
|
402
|
+
<h3>Name globbing and recursive directories under Windows</h3>
|
403
|
+
<ul>
|
404
|
+
Name globbing means matching wildcard patterns to actual file names. If you know what this
|
405
|
+
term means, you are probably annoyed at how programs on Windows typically handle this.
|
406
|
+
The Win32 version of this program goes beyond the pattern matching that Windows provides,
|
407
|
+
and allows you to specify fancy UNIX-like patterns such as:
|
408
|
+
<p>
|
409
|
+
<font size = 2 face="courier">  jhead c:\pix\199*\*\*.jpg</font>
|
410
|
+
<p>
|
411
|
+
This program goes one step beyond beyond that in that "**" as a path component means any
|
412
|
+
level of subdirectories. The invocation
|
413
|
+
<p>
|
414
|
+
<font size = 2 face="courier">  jhead c:\**\*.jpg</font>
|
415
|
+
<p>
|
416
|
+
will find ALL Jpegs files on the c: drive, including those in the root directory.
|
417
|
+
The <font size = 2 face="courier">**</font>
|
418
|
+
only works if it is the only part of that path component. For example, the path
|
419
|
+
<font size = 2 face="courier">'c:\a**\*.jpg'</font>
|
420
|
+
will not recurse.
|
421
|
+
The <font size = 2 face="courier">'**'</font>
|
422
|
+
recursive expansion is ONLY supported on the Windows version. The code is in the module 'myglob.c',
|
423
|
+
if you want to reuse it (I certainly intend to reuse that code for other applications).
|
424
|
+
Under UNIX, the shell's wildcard expansion is
|
425
|
+
pretty decent already, and dealing with the convoluted nature of some UNIX file layouts,
|
426
|
+
doing better would have been much more of a challenge.
|
427
|
+
</ul>
|
428
|
+
|
429
|
+
<h3>Programs I use with Jhead</h3>
|
430
|
+
<b>ImageMagick</b><br>
|
431
|
+
<ul>
|
432
|
+
I use the MOGIRIFY command from ImageMagick to do batch conversions and re-compresses of images.
|
433
|
+
If you use Linux, you probably already have ImageMagick on your system (just type 'mogrify' at the
|
434
|
+
command prompt to see if you have it). For Windows users, you have to download it from:
|
435
|
+
<a href="http://www.imagemagick.org"> http://www.imagemagick.org</a><p>
|
436
|
+
Image Magick is one of those programs that preserves comment and Exif headers, although older
|
437
|
+
versions do not.
|
438
|
+
</ul>
|
439
|
+
<b>JPEGTRAN</b><br>
|
440
|
+
<ul>
|
441
|
+
If you use Linux you probably also already have this program. For windows, it's hard to find a
|
442
|
+
pre-built binary on the web. The <a href="http://www.ijg.org"> Independent JPEG
|
443
|
+
Group</a>'s website only has the source code.<p>
|
444
|
+
There's a fancier version, with pre-built Windows binaries and a lossless cropping feature added at:
|
445
|
+
<a href="http://sylvana.net/jpegcrop"> http://sylvana.net/jpegcrop</a>.
|
446
|
+
</ul>
|
447
|
+
|
448
|
+
<b>XnView</b><br>
|
449
|
+
<ul>
|
450
|
+
<a href="http://www.xnview.com">XnView</a> is an excellent, small, fast, and free graphical image browser.
|
451
|
+
It makes use of jpeg thumbnails for the thumbnail view. On account of Xnview, I added
|
452
|
+
options to fix or regenerate the thumbnails to jhead, so that I could regenerate the thumnails
|
453
|
+
for images where the thumbnail had gotten out of sync with the image.
|
454
|
+
<br>
|
455
|
+
Mac and Linux versions of XnView are also available.
|
456
|
+
</ul>
|
457
|
+
|
458
|
+
<b>wrjpgcom / rdjpgcom</b><br>
|
459
|
+
<ul>
|
460
|
+
You can use these programs to write and extract COM markers from JPEG images respectively. Although I always
|
461
|
+
use my jhead program for this feature, the wrjpgcom and rdjpgcom programs are extremely simple and very
|
462
|
+
suitable for use with perl or shell scripts to process lots of images. These programs are part of most
|
463
|
+
Linux distributions as part of the libjpg package (along with jpegtran)
|
464
|
+
</ul>
|
465
|
+
<p><br>
|
466
|
+
Jhead homeage: <a href="http://www.sentex.net/~mwandel/jhead">http://www.sentex.net/~mwandel/jhead</a><br>
|
467
|
+
Last Updated: Nov 06 2009
|
468
|
+
|
469
|
+
|