mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2026-10-20 13:58:50 -04:00
expose the underlying library version in the image metadata
This commit is contained in:
+1
-1
@@ -7,6 +7,6 @@ Dependencies:
|
||||
Options:
|
||||
test-before-installing: True
|
||||
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows']
|
||||
cmake-options: "-DKIMAGEFORMATS_WITH_KNOWN_CRASHES_JXR=ON -DKIMAGEFORMATS_HEIF=ON -DKIMAGEFORMATS_HEIC_TEST:STRING=OFF -DKIMAGEFORMATS_HEIF_TEST:STRING=OFF -DKIMAGEFORMATS_HEJ2_TEST:STRING=OFF -DKIMAGEFORMATS_AVCI_TEST:STRING=OFF"
|
||||
cmake-options: "-DKIMAGEFORMATS_WITH_KNOWN_CRASHES_JXR=ON -DKIMAGEFORMATS_HEIF=ON -DKIMAGEFORMATS_HEIC_TEST:STRING=OFF -DKIMAGEFORMATS_HEIF_TEST:STRING=OFF -DKIMAGEFORMATS_HEJ2_TEST:STRING=OFF -DKIMAGEFORMATS_AVCI_TEST:STRING=OFF -DKIMAGEFORMATS_EXPOSE_LIBVER=ON"
|
||||
per-test-timeout: 90
|
||||
enable-lsan: False
|
||||
|
||||
@@ -104,6 +104,8 @@ if(KIMAGEFORMATS_WITH_KNOWN_CRASHES_JXR)
|
||||
endif()
|
||||
add_feature_info(LibJXR LibJXR_FOUND "required for the QImage plugin for JPEG XR images")
|
||||
|
||||
option(KIMAGEFORMATS_EXPOSE_LIBVER "Store the version of the underlying library in the image metadata" OFF)
|
||||
|
||||
ecm_set_disabled_deprecation_versions(
|
||||
QT 6.11.0
|
||||
KF 6.27.0
|
||||
|
||||
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
|
||||
QCoreApplication::removeLibraryPath(QStringLiteral(PLUGIN_DIR));
|
||||
QCoreApplication::addLibraryPath(QStringLiteral(PLUGIN_DIR));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("readtest"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("1.3.0"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("1.3.1"));
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(QStringLiteral("Performs basic image conversion checking."));
|
||||
@@ -352,6 +352,12 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
// version of the underlying library used, if any
|
||||
QString libVer = inputImage.text(QStringLiteral("Library"));
|
||||
if (!libVer.isEmpty()) {
|
||||
QTextStream(stdout) << "INFO : using " << libVer << "\n";
|
||||
}
|
||||
|
||||
if (!optionTest.compare(&inputReader)) {
|
||||
QTextStream(stdout) << "FAIL : " << fi.fileName() << ": error while comparing options\n";
|
||||
++failed;
|
||||
|
||||
@@ -15,6 +15,9 @@ function(kimageformats_add_plugin plugin)
|
||||
target_sources(${plugin} PRIVATE ${KIF_ADD_PLUGIN_SOURCES})
|
||||
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/imageformats)
|
||||
target_link_libraries(${plugin} PRIVATE Qt6::Gui)
|
||||
if(KIMAGEFORMATS_EXPOSE_LIBVER)
|
||||
target_compile_definitions(${plugin} PRIVATE KIF_EXPOSE_LIBVER)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
# Plugins should be named with lib prefix on Android
|
||||
|
||||
@@ -609,6 +609,10 @@ bool QAVIFHandler::read(QImage *image)
|
||||
jumpToNextImage();
|
||||
}
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
m_current_image.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("LibAVIF %1").arg(avifVersion()));
|
||||
#endif
|
||||
|
||||
*image = m_current_image;
|
||||
if (imageCount() >= 2) {
|
||||
m_must_jump_to_next_image = true;
|
||||
|
||||
@@ -83,6 +83,10 @@
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfVersion.h>
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
#include <openexr.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QColorSpace>
|
||||
@@ -553,6 +557,12 @@ bool EXRHandler::read(QImage *outImage)
|
||||
// final color operations
|
||||
readColorSpace(header, image);
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
int maj = 0, min = 0, pat = 0;
|
||||
exr_get_library_version(&maj, &min, &pat, nullptr);
|
||||
image.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("OpenEXR %1.%2.%3").arg(maj).arg(min).arg(pat));
|
||||
#endif
|
||||
|
||||
*outImage = image;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -191,6 +191,10 @@ bool HEIFHandler::read(QImage *outImage)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
m_current_image.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("LibHEIF %1").arg(heif_get_version()));
|
||||
#endif
|
||||
|
||||
*outImage = m_current_image;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -342,6 +342,11 @@ public:
|
||||
|
||||
img.setColorSpace(colorSpace());
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
quint32 ver = opjVersion();
|
||||
img.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("OpenJPEG %1.%2.%3").arg((ver >> 16) & 0xff).arg((ver >> 8) & 0xff).arg(ver & 0xff));
|
||||
#endif
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
@@ -842,6 +842,13 @@ bool QJpegXLHandler::read(QImage *image)
|
||||
}
|
||||
|
||||
if (decode_one_frame()) {
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
quint32 ver = JxlDecoderVersion();
|
||||
int maj = ver / 1000000;
|
||||
int min = (ver % 1000000) / 1000;
|
||||
int pat = ver % 1000;
|
||||
m_current_image.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("LibJXL %1.%2.%3").arg(maj).arg(min).arg(pat));
|
||||
#endif
|
||||
*image = m_current_image;
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -159,6 +159,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
quint32 jxrVersion() const
|
||||
{
|
||||
quint32 ver = 0;
|
||||
#ifdef JXR_VERSION
|
||||
# if JXR_VERSION < JXR_MAKEVERSION(1, 4, 0)
|
||||
ver = JXR_VERSION;
|
||||
# else
|
||||
PKLibJxr_GetVersion(&ver);
|
||||
# endif
|
||||
#endif
|
||||
return ver;
|
||||
}
|
||||
|
||||
QString fileName() const
|
||||
{
|
||||
return m_jxrFile->fileName();
|
||||
@@ -1164,6 +1177,12 @@ bool JXRHandler::read(QImage *outImage)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
if (auto ver = d->jxrVersion()) {
|
||||
img.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("JXRlib %1.%2.%3").arg((ver >> 16) & 0xff).arg((ver >> 8) & 0xff).arg(ver & 0xff));
|
||||
}
|
||||
#endif
|
||||
|
||||
*outImage = img;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -941,6 +941,10 @@ bool RAWHandler::read(QImage *image)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef KIF_EXPOSE_LIBVER
|
||||
img.setText(QStringLiteral(META_KEY_LIBRARY), QStringLiteral("LibRAW %1").arg(libraw_version()));
|
||||
#endif
|
||||
|
||||
*image = img;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@
|
||||
#define META_KEY_LENS_MODEL "LensModel"
|
||||
#define META_KEY_LENS_SERIALNUMBER "LensSerialNumber"
|
||||
|
||||
// The name and version of the library used (e.g. OpenEXR 3.4.2)
|
||||
#define META_KEY_LIBRARY "Library"
|
||||
|
||||
// QList uses some extra space for stuff, hence the 32 here suggested by Thiago Macieira
|
||||
static constexpr int kMaxQVectorSize = std::numeric_limits<int>::max() - 32;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user