aboutsummaryrefslogtreecommitdiffstats
path: root/src/libpyexiv2.cpp
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-01-03 23:26:09 +0100
committerOlivier Tilloy <olivier@tilloy.net>2007-01-03 23:26:09 +0100
commit8222a45b802786b5ecff4bae6a66de180d5cf964 (patch)
tree2b15786a68c10b03ca16c8eaf123bab5d84e332b /src/libpyexiv2.cpp
parent35bf3a8dcc8812a9956108f9b401f478cadc60f7 (diff)
downloadpyexiv2-8222a45b802786b5ecff4bae6a66de180d5cf964.tar.gz
Added and implemented Image::deleteThumbnail() and Image::dumpThumbnailToFile().
Diffstat (limited to 'src/libpyexiv2.cpp')
-rw-r--r--src/libpyexiv2.cpp72
1 files changed, 57 insertions, 15 deletions
diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp
index 76c06ed..6389117 100644
--- a/src/libpyexiv2.cpp
+++ b/src/libpyexiv2.cpp
@@ -41,9 +41,9 @@ namespace LibPyExiv2
_image = Exiv2::ImageFactory::open(filename);
assert(_image.get() != 0);
}
- catch(Exiv2::AnyError & e)
+ catch(Exiv2::AnyError& e)
{
- std::cerr << ">>> Image::Image(): caught Exiv2 exception '" << e << "'!";
+ std::cerr << ">>> Image::Image(): caught Exiv2 exception '" << e << "'";
}
_dataRead = false;
}
@@ -57,9 +57,9 @@ namespace LibPyExiv2
_image = Exiv2::ImageFactory::open(_filename);
assert(_image.get() != 0);
}
- catch(Exiv2::AnyError & e)
+ catch(Exiv2::AnyError& e)
{
- std::cerr << ">>> Image::Image(): caught Exiv2 exception '" << e << "'!";
+ std::cerr << ">>> Image::Image(): caught Exiv2 exception '" << e << "'";
}
_dataRead = false;
}
@@ -73,11 +73,11 @@ namespace LibPyExiv2
_iptcData = _image->iptcData();
_dataRead = true;
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// An error occured while reading the metadata
_dataRead = false;
- std::cerr << ">>> Image::readMetadata(): caught Exiv2 exception '" << e << "'!";
+ std::cerr << ">>> Image::readMetadata(): caught Exiv2 exception '" << e << "'";
}
}
@@ -91,10 +91,10 @@ namespace LibPyExiv2
_image->setIptcData(_iptcData);
_image->writeMetadata();
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// An error occured while writing the metadata
- std::cerr << ">>> Image::writeMetadata(): caught Exiv2 exception '" << e << "'!";
+ std::cerr << ">>> Image::writeMetadata(): caught Exiv2 exception '" << e << "'";
}
}
}
@@ -138,7 +138,7 @@ namespace LibPyExiv2
return boost::python::make_tuple(std::string(""), std::string(""));
}
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Exif tag key
std::cerr << ">>> Image::getExifTag(): unknown key '" << key << "'" << std::endl;
@@ -174,7 +174,7 @@ namespace LibPyExiv2
return std::string("");
}
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Exif tag key
std::cerr << ">>> Image::getExifTagToString(): unknown key '" << key << "'" << std::endl;
@@ -215,7 +215,7 @@ namespace LibPyExiv2
_exifData[key] = value;
return returnValue;
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Exif tag key
std::cerr << ">>> Image::setExifTag(): unknown key '" << key << "'" << std::endl;
@@ -252,7 +252,7 @@ namespace LibPyExiv2
}
return returnValue;
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Exif tag key
std::cerr << ">>> Image::deleteExifTag(): unknown key '" << key << "'" << std::endl;
@@ -307,7 +307,7 @@ namespace LibPyExiv2
return boost::python::make_tuple(std::string(""), std::string(""));
}
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Iptc tag key
std::cerr << ">>> Image::getIptcTag(): unknown key '" << key << "'" << std::endl;
@@ -346,7 +346,7 @@ namespace LibPyExiv2
_iptcData[key] = value;
return returnValue;
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Iptc tag key
std::cerr << ">>> Image::setIptcTag(): unknown key '" << key << "'" << std::endl;
@@ -383,7 +383,7 @@ namespace LibPyExiv2
}
return returnValue;
}
- catch(Exiv2::Error & e)
+ catch(Exiv2::Error& e)
{
// The key is not a valid Iptc tag key
std::cerr << ">>> Image::deleteIptcTag(): unknown key '" << key << "'" << std::endl;
@@ -449,4 +449,46 @@ namespace LibPyExiv2
}
}
+ void Image::deleteThumbnail()
+ {
+ if(_dataRead)
+ {
+ _exifData.eraseThumbnail();
+ }
+ else
+ {
+ std::cerr << ">>> Image::deleteThumbnail(): metadata not read yet, call Image::readMetadata() first" << std::endl;
+ }
+ }
+
+ bool Image::dumpThumbnailToFile(const std::string path)
+ {
+ if(_dataRead)
+ {
+ try
+ {
+ int result = _exifData.writeThumbnail(path);
+ if (result == 0)
+ {
+ return true;
+ }
+ else if (result == 8)
+ {
+ std::cerr << ">>> Image::dumpThumbnailToFile(): the EXIF data does not contain a thumbnail";
+ return false;
+ }
+ }
+ catch(Exiv2::Error& e)
+ {
+ std::cerr << ">>> Image::dumpThumbnailToFile(): caught Exiv2 exception '" << e << "'";
+ return false;
+ }
+ }
+ else
+ {
+ std::cerr << ">>> Image::dumpThumbnailToFile(): metadata not read yet, call Image::readMetadata() first" << std::endl;
+ return false;
+ }
+ }
+
} // End of namespace LibPyExiv2