本文整理汇总了C++中KPMetadata::setExifThumbnail方法的典型用法代码示例。如果您正苦于以下问题:C++ KPMetadata::setExifThumbnail方法的具体用法?C++ KPMetadata::setExifThumbnail怎么用?C++ KPMetadata::setExifThumbnail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KPMetadata
的用法示例。
在下文中一共展示了KPMetadata::setExifThumbnail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
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);
}
示例2: updateMetadataImageMagick
bool Utils::updateMetadataImageMagick(const QString& src, QString& err)
{
QFileInfo finfo(src);
if (src.isEmpty() || !finfo.isReadable())
{
err = i18n("unable to open source file");
return false;
}
QImage img(src);
QImage iptcPreview = img.scaled(1280, 1024, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QImage exifThumbnail = iptcPreview.scaled(160, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);
KPMetadata meta;
meta.load(src);
meta.setImageOrientation(KPMetadata::ORIENTATION_NORMAL);
meta.setImageProgramId(QString("Kipi-plugins"), QString(kipiplugins_version));
meta.setImageDimensions(img.size());
meta.setExifThumbnail(exifThumbnail);
meta.setImagePreview(iptcPreview);
#if KEXIV2_VERSION >= 0x010000
QByteArray exifData = meta.getExifEncoded(true);
#else
QByteArray exifData = meta.getExif(true);
#endif
QByteArray iptcData = meta.getIptc(true);
QByteArray xmpData = meta.getXmp();
KTemporaryFile exifTemp;
exifTemp.setSuffix(QString("kipipluginsexif.app1"));
exifTemp.setAutoRemove(true);
if ( !exifTemp.open() )
{
err = i18n("unable to open temp file");
return false;
}
QString exifFile = exifTemp.fileName();
QDataStream streamExif( &exifTemp );
streamExif.writeRawData(exifData.data(), exifData.size());
exifTemp.close();
KTemporaryFile iptcTemp;
iptcTemp.setSuffix(QString("kipipluginsiptc.8bim"));
iptcTemp.setAutoRemove(true);
iptcTemp.open();
if ( !iptcTemp.open() )
{
err = i18n("Cannot rotate: unable to open temp file");
return false;
}
QString iptcFile = iptcTemp.fileName();
QDataStream streamIptc( &iptcTemp );
streamIptc.writeRawData(iptcData.data(), iptcData.size());
iptcTemp.close();
KTemporaryFile xmpTemp;
xmpTemp.setSuffix(QString("kipipluginsxmp.xmp"));
xmpTemp.setAutoRemove(true);
if ( !xmpTemp.open() )
{
err = i18n("unable to open temp file");
return false;
}
QString xmpFile = xmpTemp.fileName();
QDataStream streamXmp( &xmpTemp );
streamXmp.writeRawData(xmpData.data(), xmpData.size());
xmpTemp.close();
KProcess process;
process.clearProgram();
process << "mogrify";
process << "-profile";
process << exifFile;
process << "-profile";
process << iptcFile;
process << "-profile";
process << xmpFile;
process << src + QString("[0]");
kDebug() << "ImageMagick Command line: " << process.program();
process.start();
if (!process.waitForFinished())
return false;
if (process.exitStatus() != QProcess::NormalExit)
return false;
switch (process.exitCode())
{
case 0: // Process finished successfully !
{
return true;
//.........这里部分代码省略.........