diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-11 15:04:55 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-18 09:29:06 +0000 |
commit | 2cd4123661d6f97a8c0889d7a4c5907fa8fbb456 (patch) | |
tree | 90bb7df4e418f15cdef65a5d45b3b2b5d162c37c /tests/auto | |
parent | 633a0f51720d149acf5dcddc8debc1f457fff835 (diff) |
QImage/Jpeg: decode/encode comment attributes as utf-8
Although not defined, the jpeg comment field 'content' is treated as
utf-8 nowadys. At least exiftool and exiv2 (tested via gwenview) are
expecting utf-8 here. So we should do the same.
Task-number: QTBUG-44709
Change-Id: If84dafac3e337c7993f09cd59792e721977c9adb
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg | bin | 0 -> 705 bytes | |||
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 29 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg Binary files differnew file mode 100644 index 0000000000..42b305f5b8 --- /dev/null +++ b/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 7ad4a9e9bb..55a670eb6f 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -192,6 +192,7 @@ private slots: void exif_QTBUG45865(); void exifInvalidData_data(); void exifInvalidData(); + void exifReadComments(); void cleanupFunctions(); @@ -3066,6 +3067,34 @@ void tst_QImage::exifInvalidData() QVERIFY(!image.isNull()); } +void tst_QImage::exifReadComments() +{ + QImage image; + QVERIFY(image.load(m_prefix + "jpeg_exif_utf8_comment.jpg")); + QVERIFY(!image.isNull()); + QCOMPARE(image.textKeys().size(), 1); + QCOMPARE(image.textKeys().first(), "Description"); + // check if exif comment is read as utf-8 + QCOMPARE(image.text("Description"), QString::fromUtf8("some unicode chars: ÖÄÜ€@")); + + QByteArray ba; + { + QBuffer buf(&ba); + QVERIFY(buf.open(QIODevice::WriteOnly)); + QVERIFY(image.save(&buf, "JPG")); + } + QVERIFY(!ba.isEmpty()); + image = QImage(); + QCOMPARE(image.textKeys().size(), 0); + { + QBuffer buf(&ba); + QVERIFY(buf.open(QIODevice::ReadOnly)); + QVERIFY(image.load(&buf, "JPG")); + } + // compare written (and reread) description text + QCOMPARE(image.text("Description"), QString::fromUtf8("some unicode chars: ÖÄÜ€@")); +} + static void cleanupFunction(void* info) { bool *called = static_cast<bool*>(info); |