diff options
-rw-r--r-- | exif.c | 21 | ||||
-rw-r--r-- | gpsinfo.c | 4 | ||||
-rw-r--r-- | jhead.h | 1 |
3 files changed, 23 insertions, 3 deletions
@@ -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 { @@ -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)) @@ -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); |