本文整理汇总了C++中exiv2::image::AutoPtr::pixelHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::pixelHeight方法的具体用法?C++ AutoPtr::pixelHeight怎么用?C++ AutoPtr::pixelHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::image::AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::pixelHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QSize
bool KExiv2::loadFromData(const QByteArray& imgData) const
{
if (imgData.isEmpty())
return false;
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
d->filePath.clear();
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = QString::fromLatin1(image->mimeType().c_str());
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load metadata using Exiv2 "), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
}
示例2: writeThumbnail
bool MetadataThumbnail::writeThumbnail(bool isMetadataEnabled)
{
isThumbnailSavedSuccessfully = false;
#ifdef SIR_METADATA_SUPPORT
if (isMetadataEnabled) {
MetadataUtils::Metadata metadata;
if (metadata.read(imagePath, true)) {
exifStruct_ = metadata.exifStruct()->copy();
iptcStruct_ = metadata.iptcStruct()->copy();
Exiv2::Image::AutoPtr image = metadata.imageAutoPtr();
imageSize = QSize(image->pixelWidth(), image->pixelHeight());
Exiv2::PreviewManager previewManager (*image);
Exiv2::PreviewPropertiesList previewList = previewManager.
getPreviewProperties();
if (previewList.empty()) {
return isThumbnailSavedSuccessfully;
}
else { // read from metadata thumnail
Exiv2::PreviewImage preview = previewManager.getPreviewImage(
previewList[0]);
preview.writeFile(thumbPath.toStdString());
thumbPath += preview.extension().c_str();
thumbSize.setWidth(preview.width());
thumbSize.setHeight(preview.height());
}
isThumbnailSavedSuccessfully = true;
return isThumbnailSavedSuccessfully;
}
else {
return isThumbnailSavedSuccessfully;
}
}
#endif // SIR_METADATA_SUPPORT
return isThumbnailSavedSuccessfully;
}
示例3: scan_exiv2
void scan_exiv2(const class scanner_params &sp,const recursion_control_block &rcb)
{
assert(sp.sp_version==scanner_params::CURRENT_SP_VERSION);
if(sp.phase==scanner_params::PHASE_STARTUP){
assert(sp.info->si_version==scanner_info::CURRENT_SI_VERSION);
sp.info->name = "exiv2";
sp.info->author = "Simson L. Garfinkel";
sp.info->description = "Searches for EXIF information using exiv2";
sp.info->scanner_version= "1.0";
sp.info->feature_names.insert("exif");
sp.info->feature_names.insert("gps");
sp.info->flags = scanner_info::SCANNER_DISABLED; // disabled because we have be_exif
return;
}
if(sp.phase==scanner_params::PHASE_SHUTDOWN) return;
if(sp.phase==scanner_params::PHASE_SCAN){
const sbuf_t &sbuf = sp.sbuf;
feature_recorder *exif_recorder = sp.fs.get_name("exif");
feature_recorder *gps_recorder = sp.fs.get_name("gps");
#ifdef HAVE_EXIV2__LOGMSG__SETLEVEL
/* New form to suppress error messages on exiv2 */
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);
#endif
size_t pos_max = 1; // by default, just scan 1 byte
if(sbuf.bufsize > min_exif_size){
pos_max = sbuf.bufsize - min_exif_size; // we can scan more!
}
/* Loop through all possible locations in the buffer */
for(size_t pos=0;pos<pos_max;pos++){
size_t count = exif_gulp_size;
count = min(count,sbuf.bufsize-pos);
//size_t count = sbuf.bufsize-pos; // use all to end
/* Explore the beginning of each 512-byte block as well as the starting location
* of any JPEG on any boundary. This will cause processing of any multimedia file
* that Exiv2 recognizes (for which I do not know all the headers.
*/
if(pos%512==0 || jpeg_start(sbuf+pos)){
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(sbuf.buf+pos,count);
if(image->good()){
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) continue;
/*
* Create the MD5 of the first 4K to use as a unique identifier.
*/
sbuf_t tohash(sbuf,0,4096);
string md5_hex = exif_recorder->fs.hasher.func(tohash.buf,tohash.bufsize);
char xmlbuf[1024];
snprintf(xmlbuf,sizeof(xmlbuf),
"<exiv2><width>%d</width><height>%d</height>",
image->pixelWidth(),image->pixelHeight());
/* Scan through the fields reported by exiv2.
* Create XML for each and extract GPS information if present.
*/
string photo_time; // use this when gps_time is not available
string gps_time;
string gps_date;
string gps_lat_ref;
string gps_lat;
string gps_lon_ref;
string gps_lon;
string gps_ele;
string gps_speed;
string gps_course;
bool has_gps = false;
bool has_gps_date = false;
string xml = xmlbuf;
for (Exiv2::ExifData::const_iterator i = exifData.begin();
i != exifData.end(); ++i) {
if(i->count()>1000) continue; // ignore long ones
string key = string(i->key());
xml.append("<"+key+">"+dfxml_writer::xmlescape(i->value().toString())+"</"+key+">");
// use Date from Photo unless date from GPS is available
if(key=="Exif.Photo.DateTimeOriginal"){
photo_time = i->value().toString();
/* change "2011/06/25 12:20:11" to "2011-06-25 12:20:11" */
std::transform(photo_time.begin(),photo_time.end(),photo_time.begin(),slash_to_dash);
/* change "2011:06:25 12:20:11" to "2011-06-25 12:20:11" */
if (photo_time[4] == ':') {
photo_time[4] = '-';
}
if (photo_time[7] == ':') {
photo_time[7] = '-';
//.........这里部分代码省略.........
示例4: xmpSidecarFileInfo
bool KExiv2::load(const QString& filePath) const
{
if (filePath.isEmpty())
{
return false;
}
d->filePath = filePath;
bool hasLoaded = false;
try
{
Exiv2::Image::AutoPtr image;
image = Exiv2::ImageFactory::open((const char*)(QFile::encodeName(filePath)).constData());
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = QString::fromLatin1(image->mimeType().c_str());
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
hasLoaded = true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load metadata from file "), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#ifdef _XMP_SUPPORT_
try
{
if (d->useXMPSidecar4Reading)
{
QString xmpSidecarPath = sidecarFilePathForFile(filePath);
QFileInfo xmpSidecarFileInfo(xmpSidecarPath);
Exiv2::Image::AutoPtr xmpsidecar;
if (xmpSidecarFileInfo.exists() && xmpSidecarFileInfo.isReadable())
{
// Read sidecar data
xmpsidecar = Exiv2::ImageFactory::open(QFile::encodeName(xmpSidecarPath).constData());
xmpsidecar->readMetadata();
// Merge
d->loadSidecarData(xmpsidecar);
hasLoaded = true;
}
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load XMP sidecar"), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#endif // _XMP_SUPPORT_
return hasLoaded;
}