Implemented print modes, part 1

v0.27.3
Andreas Huggel 22 years ago
parent 058a44c5d1
commit 47e43318a6

@ -20,13 +20,13 @@
*/ */
/* /*
File: actions.cpp File: actions.cpp
Version: $Name: $ $Revision: 1.4 $ Version: $Name: $ $Revision: 1.5 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 08-Dec-03, ahu: created History: 08-Dec-03, ahu: created
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.4 $ $RCSfile: actions.cpp,v $") EXIV2_RCSID("@(#) $Name: $ $Revision: 1.5 $ $RCSfile: actions.cpp,v $")
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
@ -121,6 +121,61 @@ namespace Action {
std::cerr << exifReadError(rc, path) << "\n"; std::cerr << exifReadError(rc, path) << "\n";
return rc; return rc;
} }
switch (Params::instance().printMode_) {
case Params::summary: printSummary(exifData); break;
case Params::interpreted: printInterpreted(exifData); break;
case Params::values: printValues(exifData); break;
case Params::hexdump: printHexdump(exifData); break;
}
return 0;
}
catch(const Exif::Error& e)
{
std::cerr << "Exif exception in print action for file "
<< path << ":\n" << e << "\n";
return 1;
} // Print::run
void Print::printSummary(const Exif::ExifData& exifData)
{
printTag(exifData, "Image.OtherTags.Make", "Camera make");
printTag(exifData, "Image.OtherTags.Model", "Camera model");
printTag(exifData, "Image.DateTime.DateTimeOriginal", "Image Timestamp");
printTag(exifData, "Image.CaptureConditions.ExposureTime", "Exposure time");
printTag(exifData, "Image.CaptureConditions.FNumber", "Aperture");
printTag(exifData, "Image.CaptureConditions.Flash", "Flash");
printTag(exifData, "Image.CaptureConditions.FocalLength", "Focal length");
printTag(exifData, "Image.CaptureConditions.MeteringMode", "Metering mode");
// Todo: Add size of IFD1 to thumbnail data size
std::cout << std::setw(15) << std::setfill(' ') << std::left
<< "Thumbnail" << ": ";
switch (exifData.thumbnailType()) {
case Exif::Thumbnail::none: std::cout << "None\n"; break;
case Exif::Thumbnail::jpeg:
std::cout << "JPEG, " << exifData.thumbnailSize() << " Bytes\n";
break;
case Exif::Thumbnail::tiff:
std::cout << "TIFF, " << exifData.thumbnailSize() << " Bytes\n";
break;
}
} // Print::printSummary
void Print::printTag(const Exif::ExifData& exifData,
const std::string& key,
const std::string& label)
{
Exif::ExifData::const_iterator md = exifData.findKey(key);
if (md != exifData.end()) {
std::cout << std::setw(15) << std::setfill(' ') << std::left
<< label << ": " << *md << "\n";
}
} // Print::printTag
void Print::printInterpreted(const Exif::ExifData& exifData)
{
Exif::ExifData::const_iterator md; Exif::ExifData::const_iterator md;
for (md = exifData.begin(); md != exifData.end(); ++md) { for (md = exifData.begin(); md != exifData.end(); ++md) {
std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right
@ -131,14 +186,52 @@ namespace Action {
<< md->tagName() << " " << md->tagName() << " "
<< std::dec << *md << "\n"; << std::dec << *md << "\n";
} }
return 0; } // Print::printInterpreted
void Print::printValues(const Exif::ExifData& exifData)
{
Exif::ExifData::const_iterator md;
for (md = exifData.begin(); md != exifData.end(); ++md) {
std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " "
<< std::setw(4) << std::setfill(' ') << std::left
<< md->ifdName() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< md->count() << " "
<< std::setw(27) << std::setfill(' ') << std::left
<< md->tagName() << " "
<< std::dec << md->value()
<< "\n";
} }
catch(const Exif::Error& e) } // Print::printValues
void Print::printHexdump(const Exif::ExifData& exifData)
{ {
std::cerr << "Exif exception in print action for file " Exif::ExifData::const_iterator md;
<< path << ":\n" << e << "\n"; for (md = exifData.begin(); md != exifData.end(); ++md) {
return 1; char *buf = new char[md->size()];
} // Print::run md->copy(buf, exifData.byteOrder());
std::cout << std::setw(4) << std::setfill(' ') << std::left
<< md->ifdName() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< md->count() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< md->size() << " "
<< std::setw(27) << std::setfill(' ') << std::left
<< md->tagName() << "\n";
Exif::hexdump(std::cout, buf, md->size());
delete[] buf;
}
} // Print::printHexdump
Print::AutoPtr Print::clone() const Print::AutoPtr Print::clone() const
{ {

@ -22,7 +22,7 @@
@file actions.hpp @file actions.hpp
@brief Implements base class Task, TaskFactory and the various supported @brief Implements base class Task, TaskFactory and the various supported
actions (derived from Task). actions (derived from Task).
@version $Name: $ $Revision: 1.1 $ @version $Name: $ $Revision: 1.2 $
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 11-Dec-03, ahu: created @date 11-Dec-03, ahu: created
@ -148,6 +148,19 @@ namespace Action {
typedef std::auto_ptr<Print> AutoPtr; typedef std::auto_ptr<Print> AutoPtr;
AutoPtr clone() const; AutoPtr clone() const;
//! Print %Exif summary information
void printSummary(const Exif::ExifData& exifData);
//! Print the interpreted value for each %Exif tag
void printInterpreted(const Exif::ExifData& exifData);
//! Print uninterpreted %Exif information
void printValues(const Exif::ExifData& exifData);
//! Print %Exif information in hexdump format
void printHexdump(const Exif::ExifData& exifData);
//! Print one summary line with a label and requested data
void Print::printTag(const Exif::ExifData& exifData,
const std::string& key,
const std::string& label);
private: private:
virtual Task* clone_() const; virtual Task* clone_() const;
}; };

Loading…
Cancel
Save