int MrwImage::pixelHeight() const
 {
     ExifData::const_iterator imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageLength"));
     if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
         return imageHeight->toLong();
     }
     return 0;
 }
Exemple #2
0
 int Cr2Image::pixelHeight() const
 {
     ExifData::const_iterator imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension"));
     if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
         return imageHeight->toLong();
     }
     return 0;
 }
 int MrwImage::pixelWidth() const
 {
     ExifData::const_iterator imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageWidth"));
     if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
         return imageWidth->toLong();
     }
     return 0;
 }
Exemple #4
0
 int Cr2Image::pixelWidth() const
 {
     ExifData::const_iterator imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension"));
     if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
         return imageWidth->toLong();
     }
     return 0;
 }
Exemple #5
0
 int Rw2Image::pixelHeight() const
 {
     ExifData::const_iterator imageHeight =
         exifData_.findKey(Exiv2::ExifKey("Exif.PanasonicRaw.SensorHeight"));
     if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
         return imageHeight->toLong();
     }
     return 0;
 }
Exemple #6
0
 int Rw2Image::pixelWidth() const
 {
     ExifData::const_iterator imageWidth =
         exifData_.findKey(Exiv2::ExifKey("Exif.PanasonicRaw.SensorWidth"));
     if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
         return imageWidth->toLong();
     }
     return 0;
 }
Exemple #7
0
QImage Exiv2Lib::getPreview()
{
    PreviewManager        loader(*mImageFile);
    PreviewPropertiesList list = loader.getPreviewProperties();

    if (list.empty())
    {
        qDebug() << "Image contains no thumbnail";
        return QImage();
    }

    PreviewProperties selected;
    // Take the last image in the list.
    // For Canon raw pictures, the 2nd preview has no white balance applied.
    // see http://lclevy.free.fr/cr2/
    //     section 2.6 IFD #2
    selected = list.back();

    // FIXME: crash hapened here when reading the QImage.
    // not quite sure what caused it

    // load the thumbnail
    PreviewImage         thumbnail = loader.getPreviewImage(selected);

    const unsigned char* tmp  = thumbnail.pData();
    size_t               size = thumbnail.size();

    QImage               thumb;

    thumb.loadFromData(tmp, size);

    // Read the EXIF orientation flag and rotate the image accordingly.
    ExifData&                data = mImageFile->exifData();
    ExifData::const_iterator pos;
    pos = data.findKey(ExifKey("Exif.Image.Orientation"));

    // TODO: should flip/rotate after resize
    if (pos != data.end())
    {
        qDebug() << "rotation" << pos->toLong();
        QTransform rotate;

        switch (pos->toLong())
        {
            case 1:     // no rotation needed
                break;

            case 2:     // flip over y
                thumb = thumb.mirrored(true, false);
                break;

            case 3:     // rotate 180 (or flip x flip y)
                thumb = thumb.mirrored(true, true);
                break;

            case 4:     // flip over x
                thumb = thumb.mirrored(false, true);
                break;

            case 5:     // rotate 90 CW & flip over y
                rotate.rotate(90);
                rotate.rotate(180, Qt::YAxis);
                thumb = thumb.transformed(rotate);
                break;

            case 6:     // rotate 90 CW
                rotate.rotate(90);
                thumb = thumb.transformed(rotate);
                break;

            case 7:     // rotate 90 CCW flip over y
                rotate.rotate(-90);
                rotate.rotate(180, Qt::YAxis);
                thumb = thumb.transformed(rotate);
                break;

            case 8:     // rotate 90 CCW
                rotate.rotate(-90);
                thumb = thumb.transformed(rotate);
                break;
        }
    }
    return thumb;
}
Exemple #8
0
gboolean
exiv2_load_meta_interface(const gchar *service, RAWFILE *rawfile, guint offset, RSMetadata *meta)
{
	try {
		Image::AutoPtr img = ImageFactory::open((byte*)raw_get_map(rawfile), raw_get_filesize(rawfile));
		img->readMetadata();
		ExifData &exifData = img->exifData();

#if EXIV2_TEST_VERSION(0,17,0)
		/* We perfer XMP data, so copy it to EXIF */
		XmpData &xmpData = img->xmpData();
		if (!xmpData.empty())
			copyXmpToExif(xmpData, exifData);
#endif

		/* Parse Exif Data */
		if (!exifData.empty())
		{
			ExifData::const_iterator i;
			i = exifData.findKey(ExifKey("Exif.Image.Make"));
			if (i != exifData.end())
				set_metadata_maker(i->toString(), meta);
			
			i = exifData.findKey(ExifKey("Exif.Image.Model"));
			if (i != exifData.end())
				meta->model_ascii = g_strdup(i->toString().c_str());

#if EXIV2_TEST_VERSION(0,19,0)
			i = orientation(exifData);
			if (i != exifData.end())
			{
				std::auto_ptr<Exiv2::Value> val = i->getValue();
				if (val->count())
				{
					switch (val->toLong())
					{
							case 6: meta->orientation = 90;
								break;
							case 8: meta->orientation = 270;
								break;
					}
				}
			}
#endif

			i = exifData.findKey(ExifKey("Exif.Image.DateTimeOriginal"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Image.DateTime"));
			if (i != exifData.end())
			{
				meta->time_ascii = g_strdup(i->toString().c_str());
				meta->timestamp = rs_exiftime_to_unixtime(meta->time_ascii);
			}

			i = exifData.findKey(ExifKey("Exif.Image.ExposureTime"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Photo.ExposureTime"));
			if (i != exifData.end())
				meta->shutterspeed = 1.0 / i->getValue()->toFloat();
			else
			{
				i = exifData.findKey(ExifKey("Exif.Image.ShutterSpeedValue"));
				if (i == exifData.end())
					i = exifData.findKey(ExifKey("Exif.Photo.ShutterSpeedValue"));
				if (i != exifData.end())
					meta->shutterspeed = 1.0 / i->toFloat();
			}

			i = exifData.findKey(ExifKey("Exif.Image.FNumber"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Photo.FNumber"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Image.ApertureValue"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Photo.ApertureValue"));
			if (i != exifData.end())
				meta->aperture = i->toFloat();

			i = exifData.findKey(ExifKey("Exif.Image.FocalLength"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.Photo.FocalLength"));
			if (i != exifData.end())
				meta->focallength = i->toFloat()-0.01;

#if EXIV2_TEST_VERSION(0,19,0)
			i = isoSpeed(exifData);
			if (i != exifData.end())
				meta->iso = i->toLong();

			/* Text based Lens Identifier */
			i = lensName(exifData);
			if (i != exifData.end())
			{
				TypeId type = i->typeId();
				if (type == unsignedShort || type == unsignedLong || type == signedShort || type == signedLong || type == unsignedByte || type == signedByte)
					meta->lens_id = i->toLong();
				else if (type == asciiString || type == string)
					meta->fixed_lens_identifier = g_strdup(i->toString().c_str());
			}
#endif

			/* Canon*/
			i = exifData.findKey(ExifKey("Exif.CanonCs.Lens"));
			if (i != exifData.end()
					&& i->value().count() >= 3
					&& i->value().typeId() == unsignedShort) 
			{
				float fu = i->value().toFloat(2);
				if (fu != 0.0) 
				{
					meta->lens_min_focal = i->toFloat(0) / fu;
					meta->lens_max_focal = i->toFloat(1) /fu;
				}
			}
			i = exifData.findKey(ExifKey("Exif.CanonCs.MinAperture"));
			if (i != exifData.end())
				meta->lens_min_aperture = (gfloat) exp(CanonEv(i->toFloat())*log(2)/2);
			i = exifData.findKey(ExifKey("Exif.CanonCs.MaxAperture"));
			if (i != exifData.end())
				meta->lens_max_aperture = (gfloat) exp(CanonEv(i->toFloat())*log(2)/2);

			/* Olympus */
			i = exifData.findKey(ExifKey("Exif.OlympusEq.MinFocalLength"));
			if (i != exifData.end())
				meta->lens_min_focal = i->toFloat();
			i = exifData.findKey(ExifKey("Exif.OlympusEq.MaxFocalLength"));
			if (i != exifData.end())
				meta->lens_max_focal = i->toFloat();


			/* Nikon */
			i = exifData.findKey(ExifKey("Exif.NikonLd1.MinFocalLength"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd2.MinFocalLength"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd3.MinFocalLength"));
			if (i != exifData.end())
				meta->lens_min_focal = 5.0 * pow(2.0, i->toLong()/24.0);

			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxFocalLength"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd2.MaxFocalLength"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxFocalLength"));
			if (i != exifData.end())
				meta->lens_max_focal = 5.0 * pow(2.0, i->toLong()/24.0);

			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxApertureAtMinFocal"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd2.MaxApertureAtMinFocal"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxApertureAtMinFocal"));
			if (i != exifData.end())
				meta->lens_min_aperture = i->toLong()/12.0;
			
			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxApertureAtMaxFocal"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd2.MaxApertureAtMaxFocal"));
			if (i == exifData.end())
				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxApertureAtMaxFocal"));
			if (i != exifData.end())
				meta->lens_max_aperture = i->toLong()/12.0;
				
			/* Fuji */
			i = exifData.findKey(ExifKey("Exif.Fujifilm.MinFocalLength"));
			if (i != exifData.end())
				meta->lens_min_focal = i->toFloat();
			i = exifData.findKey(ExifKey("Exif.Fujifilm.MaxFocalLength"));
			if (i != exifData.end())
				meta->lens_max_focal = i->toFloat();

			return TRUE;
		}
	} catch (Exiv2::Error& e) {
    g_debug("Exiv2 Metadata Loader:'%s'", e.what());
	}
	return FALSE;
}