diff --git a/src/exif.cc b/src/exif.cc index 425b8f5d..e8c31496 100644 --- a/src/exif.cc +++ b/src/exif.cc @@ -12,7 +12,7 @@ RCS information $Name: $ - $Revision: 1.2 $ + $Revision: 1.3 $ */ // ***************************************************************************** // included header files @@ -443,10 +443,8 @@ namespace Exif { if (rc) return rc; } - // Find and read Interoperability IFD in IFD1 - Ifd ifd1IopIfd(ifd1IopIfd); - rc = ifd1.readSubIfd(ifd1IopIfd, buf, byteOrder, 0xa005); - if (rc) return rc; + // Todo: Should we also look for Exif IFD and GPSInfo IFD in IFD1 + // and, if found, Interop. IFD in the Exif IFD??? // Finally, copy all metadata from the IFDs to the internal metadata metadata_.clear(); @@ -455,7 +453,6 @@ namespace Exif { add(exifIopIfd.entries()); add(gpsIfd.entries()); add(ifd1.entries()); - add(ifd1IopIfd.entries()); return 0; } // ExifData::read diff --git a/src/exif.h b/src/exif.h index a631bb6e..9b1e0c31 100644 --- a/src/exif.h +++ b/src/exif.h @@ -8,7 +8,7 @@ /*! @file exif.h @brief Encoding and decoding of %Exif data - @version $Name: $ $Revision: 1.2 $ + @version $Name: $ $Revision: 1.3 $ @author Andreas Huggel (ahu) @date 09-Jan-03, ahu: created */ @@ -159,6 +159,11 @@ namespace Exif { const char* typeName() const { return ExifTags::typeName(type_); } //! Returns the size in bytes of one element of this type long typeSize() const { return ExifTags::typeSize(type_); } + //! Returns the name of the IFD + const char* ifdName() const { return ExifTags::ifdName(ifdId_); } + //! Returns the name of the section + const char* sectionName() const + { return ExifTags::sectionName(tag_, ifdId_); } public: uint16 tag_; //!< Tag value diff --git a/src/exiftest.cc b/src/exiftest.cc index 9ddc04bf..9c4162bb 100644 --- a/src/exiftest.cc +++ b/src/exiftest.cc @@ -19,7 +19,11 @@ int main(int argc, char* const argv[]) Exif::ExifData::const_iterator i = beg; for (; i != end; ++i) { - std::cout << "0x" + std::cout << std::setw(9) << std::setfill(' ') << std::left + << i->ifdName() << " " + << std::setw(9) << std::setfill(' ') << std::left + << i->sectionName() << " " + << "0x" << std::hex << std::setw(4) << std::setfill('0') << std::right << i->tag_ << " " << std::setw(27) << std::setfill(' ') << std::left diff --git a/src/tags.cc b/src/tags.cc index 843793b4..1c3fe9bc 100644 --- a/src/tags.cc +++ b/src/tags.cc @@ -12,7 +12,7 @@ RCS information $Name: $ - $Revision: 1.1 $ + $Revision: 1.2 $ */ // ***************************************************************************** // included header files @@ -30,6 +30,43 @@ namespace { // class member definitions namespace Exif { + IfdInfo::IfdInfo(IfdId ifdId, const char* name) + : ifdId_(ifdId), name_(name) + { + } + + const IfdInfo ExifTags::ifdInfo_[] = { + IfdInfo(IfdIdNotSet, "(Unknown IFD)"), + + IfdInfo(ifd0, "IFD0"), + IfdInfo(exifIfd, "Exif"), + IfdInfo(gpsIfd, "GPSInfo"), + IfdInfo(exifMakerIfd, "MakerNote"), + IfdInfo(exifIopIfd, "Exif Iop."), + IfdInfo(ifd1, "IFD1"), + + IfdInfo(ifd1ExifIfd, "Exif (at IFD1)"), + IfdInfo(ifd1GpsIfd, "GPSInfo (at IFD1)"), + IfdInfo(ifd1MakerIfd, "MakerNote (at IFD1)"), + IfdInfo(ifd1ExifIopIfd, "Exif Iop. (at IFD1)") + }; + + SectionInfo::SectionInfo(SectionId sectionId, const char* name) + : sectionId_(sectionId), name_(name) + { + } + + const SectionInfo ExifTags::sectionInfo_[] = { + SectionInfo(SectionIdNotSet, "(Unknown Section)"), + + SectionInfo(ifd0Tiff, "IFD0"), + SectionInfo(exifIfdSection, "Exif"), + SectionInfo(gpsIfdSection, "GPSInfo"), + SectionInfo(exifIopIfdSection, "Exif Iop."), + SectionInfo(ifd1Section, "IFD1") + + }; + TagFormat::TagFormat(uint16 type, const char* name, long size) : type_(type), name_(name), size_(size) { @@ -57,10 +94,10 @@ namespace Exif { const char* name, const char* desc, IfdId ifdId, - TagSection section + SectionId sectionId ) : tag_(tag), name_(name), desc_(desc), - ifdId_(ifdId), section_(section) + ifdId_(ifdId), sectionId_(sectionId) { } @@ -234,7 +271,7 @@ namespace Exif { TagInfo(0xa420, "ImageUniqueID", "Unique image ID", exifIfd, exifIfdSection), // End of list marker - TagInfo(0xffff, "(Unknown)", "Unknown tag", IfdIdNotSet, TagSectionNotSet) + TagInfo(0xffff, "(Unknown)", "Unknown tag", IfdIdNotSet, SectionIdNotSet) }; int ExifTags::tagInfoIdx(uint16 tag, IfdId ifdId) @@ -253,6 +290,11 @@ namespace Exif { return tagInfo_[tagInfoIdx(tag, ifdId)].name_; } + const char* ExifTags::sectionName(uint16 tag, IfdId ifdId) + { + return sectionInfo_[tagInfo_[tagInfoIdx(tag, ifdId)].sectionId_].name_; + } + const char* ExifTags::typeName(uint16 type) { return tagFormat_[type].name_; @@ -263,6 +305,16 @@ namespace Exif { return tagFormat_[type].size_; } + const char* ExifTags::ifdName(IfdId ifdId) + { + return ifdInfo_[ifdId].name_; + } + + const char* ExifTags::sectionName(SectionId sectionId) + { + return sectionInfo_[sectionId].name_; + } + // ************************************************************************* // free functions diff --git a/src/tags.h b/src/tags.h index 0d687505..4233bb03 100644 --- a/src/tags.h +++ b/src/tags.h @@ -8,7 +8,7 @@ /*! @file tags.h @brief %Exif tag and type information - @version $Name: $ $Revision: 1.1 $ + @version $Name: $ $Revision: 1.2 $ @author Andreas Huggel (ahu) @date 15-Jan-03, ahu: created */ @@ -38,17 +38,33 @@ namespace Exif { //! Type to specify the IFD to which a metadata belongs enum IfdId { IfdIdNotSet, - ifd0, ifd1, exifIfd, gpsIfd, - makerNoteIfd, exifIopIfd, ifd1IopIfd }; + ifd0, exifIfd, gpsIfd, exifMakerIfd, exifIopIfd, + ifd1, ifd1ExifIfd, ifd1GpsIfd, ifd1MakerIfd, ifd1ExifIopIfd }; //! Section identifiers to logically group tags - enum TagSection { TagSectionNotSet, - ifd0Tiff, ifd1Section, exifIfdSection, gpsIfdSection, - exifIopIfdSection }; + enum SectionId { SectionIdNotSet, + ifd0Tiff, exifIfdSection, gpsIfdSection, + exifIopIfdSection, ifd1Section }; // ***************************************************************************** // class definitions + //! Contains information pertaining to one IFD + struct IfdInfo { + //! Constructor + IfdInfo(IfdId ifdId, const char* name); + IfdId ifdId_; //!< IFD id + const char* name_; //!< IFD name + }; + + //! Contains information pertaining to one section + struct SectionInfo { + //! Constructor + SectionInfo(SectionId sectionId, const char* name); + SectionId sectionId_; //!< Section id + const char* name_; //!< Section name + }; + //! Description of the format of a metadatum struct TagFormat { //! Constructor @@ -66,13 +82,13 @@ namespace Exif { const char* name, const char* desc, IfdId ifdId, - TagSection section + SectionId sectionId ); uint16 tag_; //!< Tag const char* name_; //!< One word tag label const char* desc_; //!< Short tag description IfdId ifdId_; //!< Link to the IFD - TagSection section_; //!< Section id + SectionId sectionId_; //!< Section id }; // struct TagInfo //! Container for Exif tag information. Implemented as a static class. @@ -91,13 +107,20 @@ namespace Exif { static const char* typeName(uint16 type); //! Returns the size in bytes of one element of this type static long typeSize(uint16 type); + //! Returns the name of the IFD + static const char* ifdName(IfdId ifdId); + //! Returns the name of the section + static const char* sectionName(SectionId sectionId); + //! Returns the name of the section + static const char* sectionName(uint16 tag, IfdId ifdId); private: static int tagInfoIdx(uint16 tag, IfdId ifdId); - static const TagFormat tagFormat_[]; - static const TagInfo tagInfo_[]; - + static const IfdInfo ifdInfo_[]; + static const SectionInfo sectionInfo_[]; + static const TagFormat tagFormat_[]; + static const TagInfo tagInfo_[]; }; // *****************************************************************************