本文整理汇总了C++中KPMetadata类的典型用法代码示例。如果您正苦于以下问题:C++ KPMetadata类的具体用法?C++ KPMetadata怎么用?C++ KPMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KPMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qCDebug
bool SwWindow::prepareImageForUpload(const QString& imgPath, bool isRAW, QString& caption)
{
QImage image;
if (isRAW)
{
qCDebug(KIPIPLUGINS_LOG) << "Get RAW preview " << imgPath;
KDcraw::loadRawPreview(image, imgPath);
}
else
{
image.load(imgPath);
}
if (image.isNull())
return false;
// get temporary file name
m_tmpPath = m_tmpDir + QFileInfo(imgPath).baseName().trimmed() + QString(".jpg");
// rescale image if requested
int maxDim = m_widget->m_dimensionSpB->value();
if (m_widget->m_resizeChB->isChecked() && (image.width() > maxDim || image.height() > maxDim))
{
qCDebug(KIPIPLUGINS_LOG) << "Resizing to " << maxDim;
image = image.scaled(maxDim, maxDim, Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
qCDebug(KIPIPLUGINS_LOG) << "Saving to temp file: " << m_tmpPath;
image.save(m_tmpPath, "JPEG", m_widget->m_imageQualitySpB->value());
// copy meta data to temporary image
KPMetadata meta;
if (meta.load(imgPath))
{
caption = getImageCaption(meta);
meta.setImageDimensions(image.size());
meta.setImageProgramId("Kipi-plugins", kipiplugins_version);
meta.save(m_tmpPath);
}
else
{
caption.clear();
}
return true;
}
示例2: setImage
bool ClockPhotoDialog::setImage(const KUrl& imageFile)
{
bool success = false;
if (d->imagePreview->load(imageFile.toLocalFile()))
{
// Try to read the datetime data.
KPMetadata meta;
if (meta.load(imageFile.toLocalFile()))
{
d->photoDateTime = meta.getImageDateTime();
if (d->photoDateTime.isValid())
{
// Set the datetime widget to the photo datetime.
d->calendar->setDateTime(d->photoDateTime);
d->calendar->setEnabled(true);
success = true;
}
else
{
// If datetime information couldn't be loaded, display a
// warning and disable the datetime widget.
QString warning = i18n("<font color=\"red\"><b>Could not "
"obtain<br>date and time information<br>"
"from image %1.</b></font>",
imageFile.fileName());
d->imagePreview->setText(warning);
}
}
}
else
{
// If the image couldn't be loaded, display a warning, disable all the
// GUI elements and load an empty photo into d->image.
QString warning = i18n("<font color=\"red\"><b>Could not load<br>"
"image %1.</b></font>",
imageFile.fileName());
d->imagePreview->setText(warning);
}
// Disable all the GUI elements if loading failed.
d->calendar->setEnabled(success);
return success;
}
示例3: applyMetadata
void IPTCKeywords::applyMetadata(QByteArray& iptcData)
{
KPMetadata meta;
meta.setIptc(iptcData);
QStringList newKeywords;
for (int i = 0 ; i < d->keywordsBox->count(); ++i)
{
QListWidgetItem* item = d->keywordsBox->item(i);
newKeywords.append(item->text());
}
if (d->keywordsCheck->isChecked())
meta.setIptcKeywords(d->oldKeywords, newKeywords);
else
meta.setIptcKeywords(d->oldKeywords, QStringList());
iptcData = meta.getIptc();
}
示例4: QFileInfo
bool WMWindow::prepareImageForUpload(const QString& imgPath, QString& caption)
{
QImage image;
image.load(imgPath);
if (image.isNull())
{
return false;
}
// get temporary file name
m_tmpPath = m_tmpDir + QFileInfo(imgPath).baseName().trimmed() + ".jpg";
// rescale image if requested
int maxDim = m_widget->dimension();
if (image.width() > maxDim || image.height() > maxDim)
{
kDebug() << "Resizing to " << maxDim;
image = image.scaled(maxDim, maxDim, Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
kDebug() << "Saving to temp file: " << m_tmpPath;
image.save(m_tmpPath, "JPEG", m_widget->quality());
// copy meta data to temporary image
KPMetadata meta;
if (meta.load(imgPath))
{
caption = getImageCaption(imgPath);
meta.setImageDimensions(image.size());
meta.save(m_tmpPath);
}
else
{
caption.clear();
}
return true;
}
示例5: blockSignals
void IPTCKeywords::readMetadata(QByteArray& iptcData)
{
blockSignals(true);
KPMetadata meta;
meta.setIptc(iptcData);
d->oldKeywords = meta.getIptcKeywords();
d->keywordsBox->clear();
d->keywordsCheck->setChecked(false);
if (!d->oldKeywords.isEmpty())
{
d->keywordsBox->insertItems(0, d->oldKeywords);
d->keywordsCheck->setChecked(true);
}
d->keywordEdit->setEnabled(d->keywordsCheck->isChecked());
d->keywordsBox->setEnabled(d->keywordsCheck->isChecked());
d->addKeywordButton->setEnabled(d->keywordsCheck->isChecked());
d->delKeywordButton->setEnabled(d->keywordsCheck->isChecked());
blockSignals(false);
}
示例6: info
void XMPEditWidget::apply()
{
if (d->modified && !d->isReadOnly)
{
KPImageInfo info(*d->dlg->currentItem());
if (d->contentPage->syncHOSTCommentIsChecked())
{
info.setDescription(d->contentPage->getXMPCaption());
}
d->contentPage->applyMetadata(d->exifData, d->xmpData);
if (d->originPage->syncHOSTDateIsChecked())
{
info.setDate(d->originPage->getXMPCreationDate());
}
d->originPage->applyMetadata(d->exifData, d->xmpData);
d->subjectsPage->applyMetadata(d->xmpData);
d->keywordsPage->applyMetadata(d->xmpData);
d->categoriesPage->applyMetadata(d->xmpData);
d->creditsPage->applyMetadata(d->xmpData);
d->statusPage->applyMetadata(d->xmpData);
d->propertiesPage->applyMetadata(d->xmpData);
KPMetadata meta;
meta.load((*d->dlg->currentItem()).path());
meta.setExif(d->exifData);
meta.setIptc(d->iptcData);
meta.setXmp(d->xmpData);
meta.save((*d->dlg->currentItem()).path());
d->modified = false;
}
}
示例7: applyMetadata
void IPTCSubjects::applyMetadata(QByteArray& iptcData)
{
KPMetadata meta;
meta.setIptc(iptcData);
QStringList newSubjects = subjectsList();
if (m_subjectsCheck->isChecked())
meta.setIptcSubjects(meta.getIptcSubjects(), newSubjects);
else
meta.setIptcSubjects(meta.getIptcSubjects(), QStringList());
iptcData = meta.getIptc();
}
示例8: getImageCaption
QString SwWindow::getImageCaption(const KPMetadata& meta) const
{
QString caption = meta.getCommentsDecoded();
if (!caption.isEmpty())
return caption;
if (meta.hasExif())
{
caption = meta.getExifComment();
if (!caption.isEmpty())
return caption;
}
if (meta.hasXmp())
{
caption = meta.getXmpTagStringLangAlt("Xmp.dc.description", QString(), false);
if (!caption.isEmpty())
return caption;
caption = meta.getXmpTagStringLangAlt("Xmp.exif.UserComment", QString(), false);
if (!caption.isEmpty())
return caption;
caption = meta.getXmpTagStringLangAlt("Xmp.tiff.ImageDescription", QString(), false);
if (!caption.isEmpty())
return caption;
}
if (meta.hasIptc())
{
caption = meta.getIptcTagString("Iptc.Application2.Caption", false);
if (!caption.isEmpty() && !caption.trimmed().isEmpty())
return caption;
}
return caption;
}
示例9: blockSignals
void XMPContent::readMetadata(QByteArray& xmpData)
{
blockSignals(true);
KPMetadata meta;
meta.setXmp(xmpData);
KPMetadata::AltLangMap map;
QString data;
d->headlineEdit->clear();
d->headlineCheck->setChecked(false);
data = meta.getXmpTagString("Xmp.photoshop.Headline", false);
if (!data.isNull())
{
d->headlineEdit->setText(data);
d->headlineCheck->setChecked(true);
}
d->headlineEdit->setEnabled(d->headlineCheck->isChecked());
d->captionEdit->setValid(false);
map = meta.getXmpTagStringListLangAlt("Xmp.dc.description", false);
if (!map.isEmpty())
d->captionEdit->setValues(map);
data = meta.getXmpTagString("Xmp.photoshop.CaptionWriter", false);
if (!data.isNull())
{
d->writerEdit->setText(data);
d->writerCheck->setChecked(true);
}
d->writerEdit->setEnabled(d->writerCheck->isChecked());
d->copyrightEdit->setValid(false);
map = meta.getXmpTagStringListLangAlt("Xmp.dc.rights", false);
if (!map.isEmpty())
d->copyrightEdit->setValues(map);
blockSignals(false);
}
示例10: slotItemChanged
void XMPEditWidget::slotItemChanged()
{
KPMetadata meta;
meta.load((*d->dlg->currentItem()).path());
#if KEXIV2_VERSION >= 0x010000
d->exifData = meta.getExifEncoded();
#else
d->exifData = meta.getExif();
#endif
d->iptcData = meta.getIptc();
d->xmpData = meta.getXmp();
d->contentPage->readMetadata(d->xmpData);
d->originPage->readMetadata(d->xmpData);
d->subjectsPage->readMetadata(d->xmpData);
d->keywordsPage->readMetadata(d->xmpData);
d->categoriesPage->readMetadata(d->xmpData);
d->creditsPage->readMetadata(d->xmpData);
d->statusPage->readMetadata(d->xmpData);
d->propertiesPage->readMetadata(d->xmpData);
d->isReadOnly = !KPMetadata::canWriteXmp((*d->dlg->currentItem()).path());
emit signalSetReadOnly(d->isReadOnly);
d->page_content->setEnabled(!d->isReadOnly);
d->page_origin->setEnabled(!d->isReadOnly);
d->page_subjects->setEnabled(!d->isReadOnly);
d->page_keywords->setEnabled(!d->isReadOnly);
d->page_categories->setEnabled(!d->isReadOnly);
d->page_credits->setEnabled(!d->isReadOnly);
d->page_status->setEnabled(!d->isReadOnly);
d->page_properties->setEnabled(!d->isReadOnly);
}
示例11: blockSignals
void XMPOrigin::readMetadata(QByteArray& xmpData)
{
blockSignals(true);
KPMetadata meta;
meta.setXmp(xmpData);
QString data;
QStringList code, list;
QDateTime dateTime;
QString dateTimeStr;
dateTimeStr = meta.getXmpTagString("Xmp.photoshop.DateCreated", false);
if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.xmp.CreateDate", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.xmp.ModifyDate", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.exif.DateTimeCreated", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.exif.DateTimeOriginal", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.tiff.DateTime", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.xmp.ModifyDate", false);
else if (dateTimeStr.isEmpty())
dateTimeStr = meta.getXmpTagString("Xmp.xmp.MetadataDate", false);
d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
d->dateCreatedCheck->setChecked(false);
if (!dateTimeStr.isEmpty())
{
dateTime = QDateTime::fromString(dateTimeStr, Qt::ISODate);
if (dateTime.isValid())
{
d->dateCreatedSel->setDateTime(dateTime);
d->dateCreatedCheck->setChecked(true);
}
}
d->dateCreatedSel->setEnabled(d->dateCreatedCheck->isChecked());
d->syncHOSTDateCheck->setEnabled(d->dateCreatedCheck->isChecked());
d->syncEXIFDateCheck->setEnabled(d->dateCreatedCheck->isChecked());
dateTimeStr = meta.getXmpTagString("Xmp.exif.DateTimeDigitized", false);
d->dateDigitalizedSel->setDateTime(QDateTime::currentDateTime());
d->dateDigitalizedCheck->setChecked(false);
if (!dateTimeStr.isEmpty())
{
dateTime = QDateTime::fromString(dateTimeStr, Qt::ISODate);
if (dateTime.isValid())
{
d->dateDigitalizedSel->setDateTime(dateTime);
d->dateDigitalizedCheck->setChecked(true);
}
}
d->dateDigitalizedSel->setEnabled(d->dateDigitalizedCheck->isChecked());
d->cityEdit->clear();
d->cityCheck->setChecked(false);
data = meta.getXmpTagString("Xmp.photoshop.City", false);
if (!data.isNull())
{
d->cityEdit->setText(data);
d->cityCheck->setChecked(true);
}
d->cityEdit->setEnabled(d->cityCheck->isChecked());
d->sublocationEdit->clear();
d->sublocationCheck->setChecked(false);
data = meta.getXmpTagString("Xmp.iptc.Location", false);
if (!data.isNull())
{
d->sublocationEdit->setText(data);
d->sublocationCheck->setChecked(true);
}
d->sublocationEdit->setEnabled(d->sublocationCheck->isChecked());
d->provinceEdit->clear();
d->provinceCheck->setChecked(false);
data = meta.getXmpTagString("Xmp.photoshop.State", false);
if (!data.isNull())
{
d->provinceEdit->setText(data);
d->provinceCheck->setChecked(true);
}
d->provinceEdit->setEnabled(d->provinceCheck->isChecked());
d->countryCB->setCurrentIndex(0);
d->countryCheck->setChecked(false);
data = meta.getXmpTagString("Xmp.iptc.CountryCode", false);
if (!data.isNull())
{
int item = -1;
for (int i = 0 ; i < d->countryCB->count() ; ++i)
if (d->countryCB->itemText(i).left(3) == data)
item = i;
if (item != -1)
{
d->countryCB->setCurrentIndex(item);
//.........这里部分代码省略.........
示例12: applyMetadata
void XMPContent::applyMetadata(QByteArray& exifData, QByteArray& xmpData)
{
KPMetadata meta;
meta.setExif(exifData);
meta.setXmp(xmpData);
if (d->headlineCheck->isChecked())
meta.setXmpTagString("Xmp.photoshop.Headline", d->headlineEdit->text());
else
meta.removeXmpTag("Xmp.photoshop.Headline");
KPMetadata::AltLangMap oldAltLangMap, newAltLangMap;
if (d->captionEdit->getValues(oldAltLangMap, newAltLangMap))
{
meta.setXmpTagStringListLangAlt("Xmp.dc.description", newAltLangMap, false);
if (syncEXIFCommentIsChecked())
meta.setExifComment(getXMPCaption());
if (syncJFIFCommentIsChecked())
meta.setComments(getXMPCaption().toUtf8());
}
else if (d->captionEdit->isValid())
meta.removeXmpTag("Xmp.dc.description");
if (d->writerCheck->isChecked())
meta.setXmpTagString("Xmp.photoshop.CaptionWriter", d->writerEdit->text());
else
meta.removeXmpTag("Xmp.photoshop.CaptionWriter");
if (d->copyrightEdit->getValues(oldAltLangMap, newAltLangMap))
meta.setXmpTagStringListLangAlt("Xmp.dc.rights", newAltLangMap, false);
else if (d->copyrightEdit->isValid())
meta.removeXmpTag("Xmp.dc.rights");
#if KEXIV2_VERSION >= 0x010000
exifData = meta.getExifEncoded();
#else
exifData = meta.getExif();
#endif
xmpData = meta.getXmp();
}
示例13: KUrl
bool PiwigoTalker::addPhoto(int albumId,
const QString& mediaPath,
bool rescale,
int maxWidth,
int maxHeight,
int quality)
{
KUrl mediaUrl = KUrl(mediaPath);
m_job = 0;
m_state = GE_CHECKPHOTOEXIST;
m_talker_buffer.resize(0);
m_path = mediaPath; // By default, m_path contains the original file
m_tmpPath = ""; // By default, no temporary file (except with rescaling)
m_albumId = albumId;
m_md5sum = computeMD5Sum(mediaPath);
kDebug() << mediaPath << " " << m_md5sum.toHex();
if (mediaPath.endsWith(".mp4") || mediaPath.endsWith(".MP4") ||
mediaPath.endsWith(".ogg") || mediaPath.endsWith(".OGG") ||
mediaPath.endsWith(".webm") || mediaPath.endsWith(".WEBM")) {
// Video management
// Nothing to do
} else {
// Image management
QImage image;
// Check if RAW file.
if (KPMetadata::isRawFile(mediaPath))
KDcrawIface::KDcraw::loadRawPreview(image, mediaPath);
else
image.load(mediaPath);
if (image.isNull())
{
// Invalid image
return false;
}
if (!rescale)
{
kDebug() << "Upload the original version: " << m_path;
} else {
// Rescale the image
if (image.width() > maxWidth || image.height() > maxHeight)
{
image = image.scaled(maxWidth, maxHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
m_path = m_tmpPath = KStandardDirs::locateLocal("tmp", KUrl(mediaPath).fileName());
image.save(m_path, "JPEG", quality);
kDebug() << "Upload a resized version: " << m_path ;
// Restore all metadata with EXIF
// in the resized version
KPMetadata meta;
if (meta.load(mediaPath))
{
meta.setImageProgramId(QString("Kipi-plugins"), QString(kipiplugins_version));
meta.setImageDimensions(image.size());
meta.save(m_path);
}
else
{
kDebug() << "Image " << mediaPath << " has no exif data";
}
}
}
// Metadata management
// Complete name and comment for summary sending
QFileInfo fi(mediaPath);
m_title = fi.completeBaseName();
m_comment = "";
m_author = "";
m_date = fi.created();
// Look in the Digikam database
KPImageInfo info(mediaUrl);
if (info.hasTitle() && !info.title().isEmpty())
m_title = info.title();
if (info.hasDescription() && !info.description().isEmpty())
m_comment = info.description();
if (info.hasCreators() && !info.creators().isEmpty())
m_author = info.creators().join(" / ");
if (info.hasDate())
m_date = info.date();
kDebug() << "Title: " << m_title;
kDebug() << "Comment: " << m_comment;
kDebug() << "Author: " << m_author;
//.........这里部分代码省略.........
示例14: QString
void SaveImgThread::run()
{
// Perform saving ---------------------------------------------------------------
QImage prev = d->img.scaled(1280, 1024, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QImage thumb = d->img.scaled(160, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QByteArray prof = KPWriteImage::getICCProfilFromFile(RawDecodingSettings::SRGB);
KPMetadata meta;
meta.setImageProgramId(QString("Kipi-plugins"), QString(kipiplugins_version));
meta.setImageDimensions(d->img.size());
if (d->format != QString("JPEG"))
meta.setImagePreview(prev);
meta.setExifThumbnail(thumb);
meta.setExifTagString("Exif.Image.DocumentName", QString("Scanned Image")); // not i18n
meta.setExifTagString("Exif.Image.Make", d->make);
meta.setXmpTagString("Xmp.tiff.Make", d->make);
meta.setExifTagString("Exif.Image.Model", d->model);
meta.setXmpTagString("Xmp.tiff.Model", d->model);
meta.setImageDateTime(QDateTime::currentDateTime());
meta.setImageOrientation(KPMetadata::ORIENTATION_NORMAL);
meta.setImageColorWorkSpace(KPMetadata::WORKSPACE_SRGB);
KPWriteImage wImageIface;
if (d->frmt != KSaneIface::KSaneWidget::FormatRGB_16_C)
{
QByteArray data((const char*)d->img.bits(), d->img.numBytes());
wImageIface.setImageData(data, d->img.width(), d->img.height(), false, true, prof, meta);
}
else
{
// 16 bits color depth image.
wImageIface.setImageData(d->ksaneData, d->width, d->height, true, false, prof, meta);
}
bool ret = false;
QString path;
if(d->newUrl.isLocalFile())
path = d->newUrl.toLocalFile();
else
path = d->newUrl.path();
if (d->format == QString("JPEG"))
{
ret = wImageIface.write2JPEG(path);
}
else if (d->format == QString("PNG"))
{
ret = wImageIface.write2PNG(path);
}
else if (d->format == QString("TIFF"))
{
ret = wImageIface.write2TIFF(path);
}
else
{
ret = d->img.save(path, d->format.toAscii().data());
}
emit signalComplete(d->newUrl, ret);
}
示例15: blockSignals
void IPTCEnvelope::readMetadata(QByteArray& iptcData)
{
blockSignals(true);
KPMetadata meta;
meta.setIptc(iptcData);
QString data, format, version;
QStringList list;
QDate date;
QTime time;
QString dateStr, timeStr;
d->destinationEdit->clear();
d->destinationCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.Destination", false);
if (!data.isNull())
{
d->destinationEdit->setText(data);
d->destinationCheck->setChecked(true);
}
d->destinationEdit->setEnabled(d->destinationCheck->isChecked());
d->envelopeIDEdit->clear();
d->envelopeIDCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.EnvelopeNumber", false);
if (!data.isNull())
{
d->envelopeIDEdit->setText(data);
d->envelopeIDCheck->setChecked(true);
}
d->envelopeIDEdit->setEnabled(d->envelopeIDCheck->isChecked());
d->serviceIDEdit->clear();
d->serviceIDCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.ServiceId", false);
if (!data.isNull())
{
d->serviceIDEdit->setText(data);
d->serviceIDCheck->setChecked(true);
}
d->serviceIDEdit->setEnabled(d->serviceIDCheck->isChecked());
d->unoIDEdit->clear();
d->unoIDCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.UNO", false);
if (!data.isNull())
{
d->unoIDEdit->setText(data);
d->unoIDCheck->setChecked(true);
}
d->unoIDEdit->setEnabled(d->unoIDCheck->isChecked());
d->productIDEdit->clear();
d->productIDCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.ProductId", false);
if (!data.isNull())
{
d->productIDEdit->setText(data);
d->productIDCheck->setChecked(true);
}
d->productIDEdit->setEnabled(d->productIDCheck->isChecked());
d->priorityCB->setCurrentIndex(0);
d->priorityCheck->setChecked(false);
data = meta.getIptcTagString("Iptc.Envelope.EnvelopePriority", false);
if (!data.isNull())
{
const int val = data.toInt();
if (val >= 0 && val <= 9)
{
d->priorityCB->setCurrentIndex(val);
d->priorityCheck->setChecked(true);
}
else
d->priorityCheck->setValid(false);
}
d->priorityCB->setEnabled(d->priorityCheck->isChecked());
d->formatCB->setCurrentIndex(0);
d->formatCheck->setChecked(false);
format = meta.getIptcTagString("Iptc.Envelope.FileFormat", false);
version = meta.getIptcTagString("Iptc.Envelope.FileVersion", false);
if (!format.isNull())
{
if (!version.isNull())
{
if (format.size() == 1) format.prepend("0");
//.........这里部分代码省略.........