Beispiel #1
0
bool NegativeProcessor::getRawExifTag(const char* exifTagName, int32 component, uint32* value) {
    Exiv2::ExifData::const_iterator it = m_RawExif.findKey(Exiv2::ExifKey(exifTagName));
    if ((it == m_RawExif.end()) || (it->count() < (component + 1))) return false;

    *value = static_cast<uint32>(it->toLong(component));
    return true;
}
Beispiel #2
0
 int RafImage::pixelHeight() const
 {
     Exiv2::ExifData::const_iterator heightIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension"));
     if (heightIter != exifData_.end() && heightIter->count() > 0) {
         return heightIter->toLong();
     }
     return 0;
 }
Beispiel #3
0
 int RafImage::pixelWidth() const
 {
     Exiv2::ExifData::const_iterator widthIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension"));
     if (widthIter != exifData_.end() && widthIter->count() > 0) {
         return widthIter->toLong();
     }
     return 0;
 }
Beispiel #4
0
 const long getExiv2ValueLong(Exiv2::ExifData& exifData, Exiv2::ExifData::const_iterator it)
 {
     if(it!=exifData.end() && it->count())
     {
         return it->toLong();
     }
     return 0;
 };
Beispiel #5
0
int NegativeProcessor::getRawExifTag(const char* exifTagName, int16* valueArray, int32 maxFill) {
    Exiv2::ExifData::const_iterator it = m_RawExif.findKey(Exiv2::ExifKey(exifTagName));
    if (it == m_RawExif.end()) return 0;

    int lengthToFill = std::min(maxFill, static_cast<int32>(it->count()));
    for (int i = 0; i < lengthToFill; i++)
        valueArray[i] = static_cast<int16>(it->toLong(i));
    return lengthToFill;
}
Beispiel #6
0
void ImageResolution::readexiv(char const *fn) {
  Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn);
  if (!image.get())
    return;

  image->readMetadata();
  Exiv2::ExifData &exifData = image->exifData();
  if (exifData.empty())
    return;

  Exiv2::ExifData::const_iterator end = exifData.end();
  bool havex = false;
  bool havey = false;
  bool haveunit = false;
  int unit;
  for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
    if (ok_)
      break;
    if (i->tag()==0x011a) {
      // X Resolution
      x_ = i->toFloat();
      havex = true;
    } else if (i->tag()==0x011b) {
      // Y Resolution
      y_ = i->toFloat();
      havey = true;
    } else if (i->tag()==0x0128) {
      unit = i->toLong();
    }
    ok_ = havex && havey && haveunit;
  }
  if (haveunit) {
    if (unit==3) {
      x_ *= 2.54;
      y_ *= 2.54;
    }
  }
  ok_ = havex && havey;
}
Beispiel #7
0
QVariantMap QgsExifTools::readTags( const QString &imagePath )
{
  std::unique_ptr< Exiv2::Image > image( Exiv2::ImageFactory::open( imagePath.toStdString() ) );
  if ( !image )
    return QVariantMap();

  image->readMetadata();
  Exiv2::ExifData &exifData = image->exifData();
  if ( exifData.empty() )
  {
    return QVariantMap();
  }

  QVariantMap res;
  Exiv2::ExifData::const_iterator end = exifData.end();
  for ( Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i )
  {
    const QString key = QString::fromStdString( i->key() );
    QVariant val;
    switch ( i->typeId() )
    {
      case Exiv2::asciiString:
      case Exiv2::string:
      case Exiv2::comment:
      case Exiv2::directory:
      case Exiv2::xmpText:
        val = QString::fromStdString( i->toString() );
        break;

      case Exiv2::unsignedLong:
      case Exiv2::signedLong:
        val = QVariant::fromValue( i->toLong() );
        break;

      case Exiv2::tiffDouble:
      case Exiv2::tiffFloat:
        val = QVariant::fromValue( i->toFloat() );
        break;

      case Exiv2::unsignedShort:
      case Exiv2::signedShort:
        val = QVariant::fromValue( static_cast< int >( i->toLong() ) );
        break;

      case Exiv2::unsignedRational:
      case Exiv2::signedRational:
      case Exiv2::unsignedByte:
      case Exiv2::signedByte:
      case Exiv2::undefined:
      case Exiv2::tiffIfd:
      case Exiv2::date:
      case Exiv2::time:
      case Exiv2::xmpAlt:
      case Exiv2::xmpBag:
      case Exiv2::xmpSeq:
      case Exiv2::langAlt:
      case Exiv2::invalidTypeId:
      case Exiv2::lastTypeId:
        val = QString::fromStdString( i->toString() );
        break;

    }

    res.insert( key, val );
  }
  return res;
}