summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exif.c21
-rw-r--r--gpsinfo.c4
-rw-r--r--jhead.h1
3 files changed, 23 insertions, 3 deletions
diff --git a/exif.c b/exif.c
index a70b310..a0056e0 100644
--- a/exif.c
+++ b/exif.c
@@ -1091,6 +1091,15 @@ static void writeExifTagAndData(int tag,
components = strlen((char*)value) + 1; // account for null terminator
if (components & 1) ++components; // no odd lengths
}
+ if (format == FMT_UNDEFINED && components == -1) {
+ // check if this UNDEFINED format is actually ASCII (as it usually is)
+ // if so, we can calculate the size
+ if(memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0) {
+ components = sizeof(ExifAsciiPrefix) +
+ strlen((char*)value + sizeof(ExifAsciiPrefix)) + 1;
+ if (components & 1) ++components; // no odd lengths
+ }
+ }
Put32u(Buffer+(*DirIndex) + 4, components); // Components
printf("# components: %ld", components);
if (format == FMT_STRING) {
@@ -1104,6 +1113,18 @@ static void writeExifTagAndData(int tag,
strncpy(Buffer+(*DataWriteIndex), (char*)value, components);
(*DataWriteIndex) += components;
}
+ } else if ((format == FMT_UNDEFINED) &&
+ (memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0)) {
+ // short strings can fit right in the long, otherwise have to
+ // go in the data area
+ if (components <= 4) {
+ memcpy(Buffer+(*DirIndex) + 8, (char*)value, components);
+ } else {
+ Put32u(Buffer+(*DirIndex) + 8, (*DataWriteIndex)-8); // Pointer
+ printf("copying %s to %d", (char*)value + sizeof(ExifAsciiPrefix), (*DataWriteIndex));
+ memcpy(Buffer+(*DataWriteIndex), (char*)value, components);
+ (*DataWriteIndex) += components;
+ }
} else if (!valueInString) {
Put32u(Buffer+(*DirIndex) + 8, value); // Value
} else {
diff --git a/gpsinfo.c b/gpsinfo.c
index 7eef6ba..896ad28 100644
--- a/gpsinfo.c
+++ b/gpsinfo.c
@@ -47,14 +47,12 @@ static TagTable_t GpsTags[]= {
{ 0x18, "GPSDestBearing", FMT_SRATIONAL, 1},
{ 0x19, "GPSDestDistanceRef", FMT_STRING, 2},
{ 0x1A, "GPSDestDistance", FMT_SRATIONAL, 1},
- { 0x1B, "GPSProcessingMethod", FMT_STRING, -1},
+ { 0x1B, "GPSProcessingMethod", FMT_UNDEFINED, -1},
{ 0x1C, "GPSAreaInformation", FMT_STRING, -1},
{ 0x1D, "GPSDateStamp", FMT_STRING, 11},
{ 0x1E, "GPSDifferential", FMT_SSHORT, 1},
};
-static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };
-
#define MAX_GPS_TAG (sizeof(GpsTags) / sizeof(TagTable_t))
#define EXIF_ASCII_PREFIX_LEN (sizeof(ExifAsciiPrefix))
diff --git a/jhead.h b/jhead.h
index 9d311e9..4347fe8 100644
--- a/jhead.h
+++ b/jhead.h
@@ -209,6 +209,7 @@ int IsGpsTag(const char* tag);
int GpsTagToFormatType(unsigned short tag);
int GpsTagNameToValue(const char* tagName);
TagTable_t* GpsTagToTagTableEntry(unsigned short tag);
+static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };
// iptc.c prototpyes
void show_IPTC (unsigned char * CharBuf, unsigned int length);