diff --git a/app/utils/componentsinfo.cpp b/app/utils/componentsinfo.cpp index 2d1d1a8c70..82372aa5b7 100644 --- a/app/utils/componentsinfo.cpp +++ b/app/utils/componentsinfo.cpp @@ -1,142 +1,153 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2008-07-30 * Description : digiKam components info dialog. * * Copyright (C) 2008-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "componentsinfo.h" // Qt includes #include #include #include // KDE includes #include // Local includes #include "applicationsettings.h" #include "digikam_config.h" #include "libsinfodlg.h" #include "dbstatdlg.h" #include "libopencv.h" // LibGphoto2 includes #ifdef HAVE_GPHOTO2 extern "C" { #include } #endif // HAVE_GPHOTO2 // QtAV includes #ifdef HAVE_MEDIAPLAYER # include + +extern "C" +{ +# include +# include +# include +} + #endif // HAVE_MEDIAPLAYER namespace Digikam { void showDigikamComponentsInfo() { // Set digiKam specific components info list. QMap list; #ifdef HAVE_GPHOTO2 list.insert(i18n("LibGphoto2"), QLatin1String(gp_library_version(GP_VERSION_SHORT)[0])); #else list.insert(i18n("LibGphoto2 support"), i18n("no")); #endif /* HAVE_GPHOTO2 */ #ifdef HAVE_KFILEMETADATA list.insert(i18n("Baloo support"), i18n("Yes")); #else list.insert(i18n("Baloo support"), i18n("no")); #endif /* HAVE_KFILEMETADATA */ #ifdef HAVE_AKONADICONTACT list.insert(i18n("AkonadiContact support"), i18n("Yes")); #else list.insert(i18n("AkonadiContact support"), i18n("no")); #endif /* HAVE_AKONADICONTACT */ #ifdef HAVE_MEDIAPLAYER list.insert(i18n("Media player support"), i18n("Yes")); list.insert(i18n("LibQtAV"), QString::fromLatin1("%1.%2.%3").arg(QTAV_MAJOR).arg(QTAV_MINOR).arg(QTAV_PATCH)); + list.insert(i18n("LibAVFormat"), QString::fromLatin1("%1.%2.%3").arg(LIBAVFORMAT_VERSION_MAJOR).arg(LIBAVFORMAT_VERSION_MINOR).arg(LIBAVFORMAT_VERSION_MICRO)); + list.insert(i18n("LibAVCodec"), QString::fromLatin1("%1.%2.%3").arg(LIBAVCODEC_VERSION_MAJOR).arg(LIBAVCODEC_VERSION_MINOR).arg(LIBAVCODEC_VERSION_MICRO)); + list.insert(i18n("LibAVUtil"), QString::fromLatin1("%1.%2.%3").arg(LIBAVUTIL_VERSION_MAJOR).arg(LIBAVUTIL_VERSION_MINOR).arg(LIBAVUTIL_VERSION_MICRO)); #else list.insert(i18n("Media player support"), i18n("no")); #endif /* HAVE_MEDIAPLAYER */ #ifdef HAVE_DBUS list.insert(i18n("DBus support"), i18n("Yes")); #else list.insert(i18n("DBus support"), i18n("no")); #endif /* HAVE_DBUS */ #ifdef HAVE_PANORAMA list.insert(i18n("Panorama support"), i18n("yes")); #else list.insert(i18n("Panorama support"), i18n("no")); #endif /* HAVE_PANORAMA */ #ifdef HAVE_HTMLGALLERY list.insert(i18n("HTML Gallery support"), i18n("yes")); #else list.insert(i18n("HTML Gallery support"), i18n("no")); #endif /* HAVE_HTMLGALLERY */ #ifdef HAVE_KCALENDAR list.insert(i18n("Calendar support"), i18n("yes")); #else list.insert(i18n("Calendar support"), i18n("no")); #endif /* HAVE_KCALENDAR */ list.insert(i18n("LibOpenCV"), QLatin1String(CV_VERSION)); // Database Backend information QString dbBe = ApplicationSettings::instance()->getDbEngineParameters().databaseType; list.insert(i18n("Database backend"), dbBe); if (dbBe != QLatin1String("QSQLITE")) { QString internal = ApplicationSettings::instance()->getDbEngineParameters().internalServer? i18n("Yes") : i18n("No"); list.insert(i18n("Database internal server"), internal); } LibsInfoDlg* const dlg = new LibsInfoDlg(qApp->activeWindow()); dlg->setInfoMap(list); dlg->show(); } void showDigikamDatabaseStat() { DBStatDlg* const dlg = new DBStatDlg(qApp->activeWindow()); dlg->show(); } } // namespace Digikam diff --git a/libs/dmetadata/dmetadata_ffmpeg.cpp b/libs/dmetadata/dmetadata_ffmpeg.cpp index 04d0f7f433..e39f9bd376 100644 --- a/libs/dmetadata/dmetadata_ffmpeg.cpp +++ b/libs/dmetadata/dmetadata_ffmpeg.cpp @@ -1,217 +1,219 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2018-02-26 * Description : metadata extraction with ffmpeg (libav) * * Copyright (C) 2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "dmetadata.h" // C Ansi includes #include // Qt includes #include // Local incudes #include "digikam_debug.h" #include "digikam_config.h" #ifdef HAVE_MEDIAPLAYER // Libav includes extern "C" { #include #include #include } #endif namespace Digikam { bool DMetadata::loadUsingFFmpeg(const QString& filePath) const { #ifdef HAVE_MEDIAPLAYER + qCDebug(DIGIKAM_METAENGINE_LOG) << "Parse metadada with FFMpeg:" << filePath; + av_register_all(); AVFormatContext* fmt_ctx = avformat_alloc_context(); int ret = avformat_open_input(&fmt_ctx, filePath.toUtf8().data(), NULL, NULL); if (ret < 0) { qCDebug(DIGIKAM_METAENGINE_LOG) << "avformat_open_input error: " << ret; return false; } ret = avformat_find_stream_info(fmt_ctx, NULL); if (ret < 0) { qCDebug(DIGIKAM_METAENGINE_LOG) << "avform_find_stream_info error: " << ret; return false; } int totalSecs = fmt_ctx->duration / AV_TIME_BASE; int bitrate = fmt_ctx->bit_rate; setXmpTagString("Xmp.video.Duration", QString::number(totalSecs), false); setXmpTagString("Xmp.video.MaxBitRate", QString::number(bitrate), false); for (uint i = 0 ; i < fmt_ctx->nb_streams ; i++) { const AVStream* const stream = fmt_ctx->streams[i]; AVCodecParameters* const codec = stream->codecpar; if (codec->codec_type == AVMEDIA_TYPE_AUDIO || codec->codec_type == AVMEDIA_TYPE_VIDEO) { /* if (codec->codec_type == AVMEDIA_TYPE_AUDIO) { subRes.addType( NFO::Audio() ); subRes.addProperty( NFO::sampleRate(), codec->sample_rate ); subRes.addProperty( NFO::channels(), codec->channels ); } */ if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { int aspectRatio = codec->sample_aspect_ratio.num; int frameRate = stream->avg_frame_rate.num; if (codec->sample_aspect_ratio.den) aspectRatio /= codec->sample_aspect_ratio.den; if (stream->avg_frame_rate.den) frameRate /= stream->avg_frame_rate.den; setXmpTagString("Xmp.video.SourceImageWidth", QString::number(codec->width), false); setXmpTagString("Xmp.video.SourceImageHeight", QString::number(codec->height), false); if (aspectRatio) setXmpTagString("Xmp.video.AspectRatio", QString::number(aspectRatio), false); if (frameRate) setXmpTagString("Xmp.video.FrameRate", QString::number(frameRate), false); setXmpTagString("Xmp.video.PixelDepth", QString::number(codec->bits_per_coded_sample), false); //TODO: codec->format => "Xmp.video.Format" (the pixel format, the value corresponds to enum AVPixelFormat). //TODO: codec->color_space => "Xmp.video.ColorSpace" (the YUV colorspace type, the value corresponds to enum AVColorSpace). } } } AVDictionary* const dict = fmt_ctx->metadata; AVDictionaryEntry* entry = av_dict_get(dict, "title", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Title", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "author", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Artist", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "copyright", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Copyright", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "comment", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Comment", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "album", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Album", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "genre", NULL, 0); if (entry) { setXmpTagString("Xmp.video.Genre", QString::fromUtf8(entry->value), false); } entry = av_dict_get(dict, "track", NULL, 0); if (entry) { QString value = QString::fromUtf8(entry->value); bool ok = false; int track = value.toInt(&ok); if (ok && track) setXmpTagString("Xmp.video.TrackNumber", QString::number(track), false); } entry = av_dict_get(dict, "year", NULL, 0); if (entry) { int year = QString::fromUtf8(entry->value).toInt(); setXmpTagString("Xmp.video.Year", QString::number(year), false); } entry = av_dict_get(dict, "creation_time", NULL, 0); if (entry) { setXmpTagString("Xmp.video.CreationDate", QString::fromUtf8(entry->value), false); } // GPS info as string. ex: "+44.8511-000.6229/" entry = av_dict_get(dict, "location", NULL, 0); if (entry) { setXmpTagString("Xmp.video.LocationInfo", QString::fromUtf8(entry->value), false); } avformat_close_input(&fmt_ctx); return true; #else Q_UNUSED(filePath); return false; #endif } } // namespace Digikam diff --git a/tests/dmetadata/CMakeLists.txt b/tests/dmetadata/CMakeLists.txt index 5fc7df95c3..f85f5f7dfe 100644 --- a/tests/dmetadata/CMakeLists.txt +++ b/tests/dmetadata/CMakeLists.txt @@ -1,154 +1,90 @@ # # Copyright (c) 2015, by Veaceslav Munteanu, # Copyright (c) 2010-2018, by Gilles Caulier, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif (POLICY CMP0063) include_directories( $ $ $ ) -add_executable(metareaderthread metareaderthread.cpp) -ecm_mark_nongui_executable(metareaderthread) -target_link_libraries(metareaderthread - digikamcore - Qt5::Core -) +macro(METADATA_TESTS_BUILD) + + set(_filename ${ARGV0}) + string(REPLACE "." ";" _temp ${_filename}) + list(GET _temp 0 _target) + + set(${_target}_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${_target}.cpp) + + add_executable(${_target} ${${_target}_SRCS}) + ecm_mark_nongui_executable(${target}) + + target_link_libraries(${_target} + digikamcore + Qt5::Core + KF5::I18n + ) + +ENDMACRO() + +# ---------------------------------------------------------------------------------- + +METADATA_TESTS_BUILD(setiptcpreview.cpp) +METADATA_TESTS_BUILD(metareaderthread.cpp) +METADATA_TESTS_BUILD(loadfromba.cpp) +METADATA_TESTS_BUILD(loadfromfile_info.cpp) +METADATA_TESTS_BUILD(loadfromfile_exif.cpp) +METADATA_TESTS_BUILD(loadfromfile_iptc.cpp) +METADATA_TESTS_BUILD(loadfromfile_xmp.cpp) +METADATA_TESTS_BUILD(erasetag.cpp) +METADATA_TESTS_BUILD(printtagslist.cpp) +METADATA_TESTS_BUILD(usexmpsidecar.cpp) +METADATA_TESTS_BUILD(readimagewritexmpsidecar.cpp) +METADATA_TESTS_BUILD(setxmpface.cpp) + +# ---------------------------------------------------------------------------------- + set(testTag_SRCS tagsreadwritetest.cpp) add_executable(tagsReadWriteTest ${testTag_SRCS}) add_test(tagsReadWriteTest tagsReadWriteTest) ecm_mark_as_test(tagsReadWriteTest) target_link_libraries(tagsReadWriteTest digikamcore - Qt5::Core Qt5::Test - KF5::I18n ) set(testRating_SRCS ratingreadwritetest.cpp) add_executable(ratingReadWriteTest ${testRating_SRCS}) add_test(ratingReadWriteTest ratingReadWriteTest) ecm_mark_as_test(ratingReadWriteTest) target_link_libraries(ratingReadWriteTest digikamcore - Qt5::Core Qt5::Test - KF5::I18n ) set(testComment_SRCS commentreadwritetest.cpp) add_executable(commentReadWriteTest ${testComment_SRCS}) add_test(commentReadWriteTest commentReadWriteTest) ecm_mark_as_test(commentReadWriteTest) target_link_libraries(commentReadWriteTest digikamcore - Qt5::Core Qt5::Test - - KF5::I18n -) - -set(setiptcpreview_SRCS setiptcpreview.cpp) -add_executable(setiptcpreview ${setiptcpreview_SRCS}) -ecm_mark_nongui_executable(setiptcpreview) -target_link_libraries(setiptcpreview - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(loadfromba_SRCS loadfromba.cpp) -add_executable(loadfromba ${loadfromba_SRCS}) -ecm_mark_nongui_executable(loadfromba) -target_link_libraries(loadfromba - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(loadfromfile_SRCS loadfromfile.cpp) -add_executable(loadfromfile ${loadfromfile_SRCS}) -ecm_mark_nongui_executable(loadfromfile) -target_link_libraries(loadfromfile - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(erasetag_SRCS erasetag.cpp) -add_executable(erasetag ${erasetag_SRCS}) -ecm_mark_nongui_executable(erasetag) -target_link_libraries(erasetag - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(printtagslist_SRCS printtagslist.cpp) -add_executable(printtagslist ${printtagslist_SRCS}) -ecm_mark_nongui_executable(printtagslist) -target_link_libraries(printtagslist - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(usexmpsidecar_SRCS usexmpsidecar.cpp) -add_executable(usexmpsidecar ${usexmpsidecar_SRCS}) -ecm_mark_nongui_executable(usexmpsidecar) -target_link_libraries(usexmpsidecar - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(readimagewritexmpsidecar_SRCS readimagewritexmpsidecar.cpp) -add_executable(readimagewritexmpsidecar ${readimagewritexmpsidecar_SRCS}) -ecm_mark_nongui_executable(readimagewritexmpsidecar) -target_link_libraries(readimagewritexmpsidecar - digikamcore - - Qt5::Core - - KF5::I18n -) - -set(setxmpface_SRCS setxmpface.cpp) -add_executable(setxmpface ${setxmpface_SRCS}) -ecm_mark_nongui_executable(setxmpface) -target_link_libraries(setxmpface - digikamcore - - Qt5::Core - KF5::I18n ) diff --git a/tests/dmetadata/loadfromfile.cpp b/tests/dmetadata/loadfromfile_exif.cpp similarity index 56% copy from tests/dmetadata/loadfromfile.cpp copy to tests/dmetadata/loadfromfile_exif.cpp index 871b93acc9..5e808444cf 100644 --- a/tests/dmetadata/loadfromfile.cpp +++ b/tests/dmetadata/loadfromfile_exif.cpp @@ -1,69 +1,68 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2009-06-11 - * Description : a command line tool to load metadata from file + * Description : a command line tool to show all EXIF metadata from file * * Copyright (C) 2009-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ // Qt includes #include #include #include // Local includes #include "dmetadata.h" using namespace Digikam; -int main (int argc, char **argv) +int main (int argc, char** argv) { QApplication app(argc, argv); if (argc != 2) { - qDebug() << "loadfromfile - test to load metadata from file and print main tags"; + qDebug() << "loadfromfile_exif - load and print all exif metadata from file"; qDebug() << "Usage: "; return -1; } QString filePath = QString::fromLocal8Bit(argv[1]); DMetadata meta; meta.load(filePath); - qDebug() << "--- Comments -------------------------------"; - qDebug() << meta.getImageComments(); - qDebug() << "--- Titles -------------------------------"; - qDebug() << meta.getImageTitles(); - qDebug() << "--- IPTC info -------------------------------"; - qDebug() << meta.getCreatorContactInfo(); - qDebug() << meta.getIptcCoreLocation(); - qDebug() << meta.getIptcCoreSubjects(); - qDebug() << "--- Media info -------------------------------"; - qDebug() << meta.getPhotographInformation(); - qDebug() << meta.getVideoInformation(); - qDebug() << "--- XMP info -------------------------------"; - qDebug() << meta.getXmpKeywords(); - qDebug() << meta.getXmpSubjects(); - qDebug() << meta.getXmpSubCategories(); + DMetadata::MetaDataMap map = meta.getExifTagsDataList(); + + if (map.isEmpty()) + { + qDebug() << "No metadata to show..."; + } + else + { + for (DMetadata::MetaDataMap::const_iterator it = map.constBegin(); + it != map.constEnd() ; ++it) + { + qDebug() << it.key() << "::" << it.value(); + } + } return 0; } diff --git a/tests/dmetadata/loadfromfile.cpp b/tests/dmetadata/loadfromfile_info.cpp similarity index 90% copy from tests/dmetadata/loadfromfile.cpp copy to tests/dmetadata/loadfromfile_info.cpp index 871b93acc9..d1a9e66700 100644 --- a/tests/dmetadata/loadfromfile.cpp +++ b/tests/dmetadata/loadfromfile_info.cpp @@ -1,69 +1,69 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2009-06-11 - * Description : a command line tool to load metadata from file + * Description : a command line tool to load main info from file * * Copyright (C) 2009-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ // Qt includes #include #include #include // Local includes #include "dmetadata.h" using namespace Digikam; -int main (int argc, char **argv) +int main (int argc, char** argv) { QApplication app(argc, argv); if (argc != 2) { - qDebug() << "loadfromfile - test to load metadata from file and print main tags"; + qDebug() << "loadfromfile_info - test to load metadata from file and print main info tags"; qDebug() << "Usage: "; return -1; } QString filePath = QString::fromLocal8Bit(argv[1]); DMetadata meta; meta.load(filePath); qDebug() << "--- Comments -------------------------------"; qDebug() << meta.getImageComments(); qDebug() << "--- Titles -------------------------------"; qDebug() << meta.getImageTitles(); qDebug() << "--- IPTC info -------------------------------"; qDebug() << meta.getCreatorContactInfo(); qDebug() << meta.getIptcCoreLocation(); qDebug() << meta.getIptcCoreSubjects(); qDebug() << "--- Media info -------------------------------"; qDebug() << meta.getPhotographInformation(); qDebug() << meta.getVideoInformation(); qDebug() << "--- XMP info -------------------------------"; qDebug() << meta.getXmpKeywords(); qDebug() << meta.getXmpSubjects(); qDebug() << meta.getXmpSubCategories(); return 0; } diff --git a/tests/dmetadata/loadfromfile.cpp b/tests/dmetadata/loadfromfile_iptc.cpp similarity index 56% copy from tests/dmetadata/loadfromfile.cpp copy to tests/dmetadata/loadfromfile_iptc.cpp index 871b93acc9..0097d433c3 100644 --- a/tests/dmetadata/loadfromfile.cpp +++ b/tests/dmetadata/loadfromfile_iptc.cpp @@ -1,69 +1,68 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2009-06-11 - * Description : a command line tool to load metadata from file + * Description : a command line tool to load all IPTC metadata from file * * Copyright (C) 2009-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ // Qt includes #include #include #include // Local includes #include "dmetadata.h" using namespace Digikam; -int main (int argc, char **argv) +int main (int argc, char** argv) { QApplication app(argc, argv); if (argc != 2) { - qDebug() << "loadfromfile - test to load metadata from file and print main tags"; + qDebug() << "loadfromfile_iptc - load and print all iptc metadata from file"; qDebug() << "Usage: "; return -1; } QString filePath = QString::fromLocal8Bit(argv[1]); DMetadata meta; meta.load(filePath); - qDebug() << "--- Comments -------------------------------"; - qDebug() << meta.getImageComments(); - qDebug() << "--- Titles -------------------------------"; - qDebug() << meta.getImageTitles(); - qDebug() << "--- IPTC info -------------------------------"; - qDebug() << meta.getCreatorContactInfo(); - qDebug() << meta.getIptcCoreLocation(); - qDebug() << meta.getIptcCoreSubjects(); - qDebug() << "--- Media info -------------------------------"; - qDebug() << meta.getPhotographInformation(); - qDebug() << meta.getVideoInformation(); - qDebug() << "--- XMP info -------------------------------"; - qDebug() << meta.getXmpKeywords(); - qDebug() << meta.getXmpSubjects(); - qDebug() << meta.getXmpSubCategories(); + DMetadata::MetaDataMap map = meta.getIptcTagsDataList(); + + if (map.isEmpty()) + { + qDebug() << "No metadata to show..."; + } + else + { + for (DMetadata::MetaDataMap::const_iterator it = map.constBegin(); + it != map.constEnd() ; ++it) + { + qDebug() << it.key() << "::" << it.value(); + } + } return 0; } diff --git a/tests/dmetadata/loadfromfile.cpp b/tests/dmetadata/loadfromfile_xmp.cpp similarity index 56% rename from tests/dmetadata/loadfromfile.cpp rename to tests/dmetadata/loadfromfile_xmp.cpp index 871b93acc9..6aacd84504 100644 --- a/tests/dmetadata/loadfromfile.cpp +++ b/tests/dmetadata/loadfromfile_xmp.cpp @@ -1,69 +1,68 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2009-06-11 - * Description : a command line tool to load metadata from file + * Description : a command line tool to load all XMP metadata from file * * Copyright (C) 2009-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ // Qt includes #include #include #include // Local includes #include "dmetadata.h" using namespace Digikam; -int main (int argc, char **argv) +int main (int argc, char** argv) { QApplication app(argc, argv); if (argc != 2) { - qDebug() << "loadfromfile - test to load metadata from file and print main tags"; + qDebug() << "loadfromfile_xmp - load and print all xmp metadata from file"; qDebug() << "Usage: "; return -1; } QString filePath = QString::fromLocal8Bit(argv[1]); DMetadata meta; meta.load(filePath); - qDebug() << "--- Comments -------------------------------"; - qDebug() << meta.getImageComments(); - qDebug() << "--- Titles -------------------------------"; - qDebug() << meta.getImageTitles(); - qDebug() << "--- IPTC info -------------------------------"; - qDebug() << meta.getCreatorContactInfo(); - qDebug() << meta.getIptcCoreLocation(); - qDebug() << meta.getIptcCoreSubjects(); - qDebug() << "--- Media info -------------------------------"; - qDebug() << meta.getPhotographInformation(); - qDebug() << meta.getVideoInformation(); - qDebug() << "--- XMP info -------------------------------"; - qDebug() << meta.getXmpKeywords(); - qDebug() << meta.getXmpSubjects(); - qDebug() << meta.getXmpSubCategories(); + DMetadata::MetaDataMap map = meta.getXmpTagsDataList(); + + if (map.isEmpty()) + { + qDebug() << "No metadata to show..."; + } + else + { + for (DMetadata::MetaDataMap::const_iterator it = map.constBegin(); + it != map.constEnd() ; ++it) + { + qDebug() << it.key() << "::" << it.value(); + } + } return 0; }