mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kutils: better Exif orientation detection
Exiv2::orientation() checks for 12 keys in total returning the first found Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4900d60892
commit
c12c142ccc
1 changed files with 6 additions and 9 deletions
|
@ -170,22 +170,19 @@ bool KExiv2::rotateImage(QImage &image) const
|
|||
// https://exiv2.org/tags-xmp-tiff.html
|
||||
int orientation = 0;
|
||||
if (d->m_exiv2image.get()) {
|
||||
static const std::string s_orientationkey = std::string("Exif.Image.Orientation");
|
||||
try {
|
||||
kDebug() << "Checking for orientation Exif data for" << d->m_path;
|
||||
const Exiv2::ExifData exiv2data = d->m_exiv2image->exifData();
|
||||
for (Exiv2::ExifData::const_iterator it = exiv2data.begin(); it != exiv2data.end(); it++) {
|
||||
const std::string key = (*it).key();
|
||||
if (key != s_orientationkey) {
|
||||
continue;
|
||||
}
|
||||
const Exiv2::ExifData::const_iterator exiv2orientation = Exiv2::orientation(exiv2data);
|
||||
if (exiv2orientation != exiv2data.end()) {
|
||||
#if defined(EXIV2_TEST_VERSION) && EXIV2_TEST_VERSION(0, 28, 0)
|
||||
orientation = (*it).value().toInt64();
|
||||
orientation = (*exiv2orientation).value().toInt64();
|
||||
#else
|
||||
orientation = (*it).value().toLong();
|
||||
orientation = (*exiv2orientation).value().toLong();
|
||||
#endif
|
||||
kDebug() << "Found orientation Exif data" << orientation;
|
||||
break;
|
||||
} else {
|
||||
kDebug() << "No orientation Exif data for" << d->m_path;
|
||||
}
|
||||
} catch(Exiv2::Error &err) {
|
||||
kWarning() << err.what() << static_cast<int>(err.code());
|
||||
|
|
Loading…
Add table
Reference in a new issue