mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +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
|
// https://exiv2.org/tags-xmp-tiff.html
|
||||||
int orientation = 0;
|
int orientation = 0;
|
||||||
if (d->m_exiv2image.get()) {
|
if (d->m_exiv2image.get()) {
|
||||||
static const std::string s_orientationkey = std::string("Exif.Image.Orientation");
|
|
||||||
try {
|
try {
|
||||||
kDebug() << "Checking for orientation Exif data for" << d->m_path;
|
kDebug() << "Checking for orientation Exif data for" << d->m_path;
|
||||||
const Exiv2::ExifData exiv2data = d->m_exiv2image->exifData();
|
const Exiv2::ExifData exiv2data = d->m_exiv2image->exifData();
|
||||||
for (Exiv2::ExifData::const_iterator it = exiv2data.begin(); it != exiv2data.end(); it++) {
|
const Exiv2::ExifData::const_iterator exiv2orientation = Exiv2::orientation(exiv2data);
|
||||||
const std::string key = (*it).key();
|
if (exiv2orientation != exiv2data.end()) {
|
||||||
if (key != s_orientationkey) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#if defined(EXIV2_TEST_VERSION) && EXIV2_TEST_VERSION(0, 28, 0)
|
#if defined(EXIV2_TEST_VERSION) && EXIV2_TEST_VERSION(0, 28, 0)
|
||||||
orientation = (*it).value().toInt64();
|
orientation = (*exiv2orientation).value().toInt64();
|
||||||
#else
|
#else
|
||||||
orientation = (*it).value().toLong();
|
orientation = (*exiv2orientation).value().toLong();
|
||||||
#endif
|
#endif
|
||||||
kDebug() << "Found orientation Exif data" << orientation;
|
kDebug() << "Found orientation Exif data" << orientation;
|
||||||
break;
|
} else {
|
||||||
|
kDebug() << "No orientation Exif data for" << d->m_path;
|
||||||
}
|
}
|
||||||
} catch(Exiv2::Error &err) {
|
} catch(Exiv2::Error &err) {
|
||||||
kWarning() << err.what() << static_cast<int>(err.code());
|
kWarning() << err.what() << static_cast<int>(err.code());
|
||||||
|
|
Loading…
Add table
Reference in a new issue