refactored code for extracting image dimensions from metadata
(cherry picked from commit 0ece9c5bfad09bc9052238d83fa696ef39effaaa)
This commit is contained in:
committed by
Lawrence Lee
parent
0102fca563
commit
92befa7e81
@@ -448,6 +448,29 @@ void Exiv2Metadata::setExifKeys(const std::vector<std::string> *keys)
|
||||
}
|
||||
|
||||
|
||||
void Exiv2Metadata::getDimensions(int &w, int &h) const
|
||||
{
|
||||
if (image_) {
|
||||
if (dynamic_cast<const Exiv2::XmpSidecar *>(image_.get())) {
|
||||
auto &exif = image_->exifData();
|
||||
auto itw = exif.findKey(Exiv2::ExifKey("Exif.Image.ImageWidth"));
|
||||
auto ith = exif.findKey(Exiv2::ExifKey("Exif.Image.ImageLength"));
|
||||
if (itw != exif.end() && ith != exif.end()) {
|
||||
w = itw->toLong();
|
||||
h = ith->toLong();
|
||||
} else {
|
||||
w = h = -1;
|
||||
}
|
||||
} else {
|
||||
w = image_->pixelWidth();
|
||||
h = image_->pixelHeight();
|
||||
}
|
||||
} else {
|
||||
w = h = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Glib::ustring Exiv2Metadata::xmpSidecarPath(const Glib::ustring &path)
|
||||
{
|
||||
Glib::ustring fn = path;
|
||||
|
||||
Reference in New Issue
Block a user