Use exiv2 for metadata handling

This commit is contained in:
Alberto Griggio
2019-05-06 09:27:44 +02:00
parent a2e2ace1c8
commit c360fd7e2c
49 changed files with 1359 additions and 17510 deletions

View File

@@ -26,8 +26,6 @@
#include <string>
#include <glibmm.h>
#include <ctime>
#include "../rtexif/rtexif.h"
#include "rawmetadatalocation.h"
#include "iimage.h"
#include "utils.h"
#include "../rtgui/threadutils.h"
@@ -49,14 +47,15 @@ enum RenderingIntent : int;
namespace procparams
{
class ProcParams;
class IPTCPairs;
typedef std::map<Glib::ustring, Glib::ustring> ExifPairs;
typedef std::map<Glib::ustring, std::vector<Glib::ustring>> IPTCPairs;
struct RAWParams;
struct ColorManagementParams;
struct CropParams;
enum class ToneCurveMode : int;
class ProcParams;
}
@@ -73,76 +72,54 @@ class FramesMetaData
{
public:
/** @return Returns the number of root Metadata */
virtual unsigned int getRootCount () const = 0;
/** @return Returns the number of frame contained in the file based on Metadata */
virtual unsigned int getFrameCount () const = 0;
virtual unsigned int getFrameCount() const = 0;
/** Checks the availability of exif metadata tags.
* @return Returns true if image contains exif metadata tags */
virtual bool hasExif (unsigned int frame = 0) const = 0;
/** Returns the directory of exif metadata tags.
* @param root root number in the metadata tree
* @return The directory of exif metadata tags */
virtual rtexif::TagDirectory* getRootExifData (unsigned int root = 0) const = 0;
/** Returns the directory of exif metadata tags.
* @param frame frame number in the metadata tree
* @return The directory of exif metadata tags */
virtual rtexif::TagDirectory* getFrameExifData (unsigned int frame = 0) const = 0;
/** Returns the directory of exif metadata tags containing at least the 'Make' tag for the requested frame.
* If no usable metadata exist in the frame, send back the best TagDirectory describing the frame content.
* @param imgSource rawimage that we want the metadata from
* @param rawParams RawParams to select the frame number
* @return The directory of exif metadata tags containing at least the 'Make' tag */
virtual rtexif::TagDirectory* getBestExifData (ImageSource *imgSource, procparams::RAWParams *rawParams) const = 0;
/** Checks the availability of IPTC tags.
* @return Returns true if image contains IPTC tags */
virtual bool hasIPTC (unsigned int frame = 0) const = 0;
/** Returns the directory of IPTC tags.
* @return The directory of IPTC tags */
virtual procparams::IPTCPairs getIPTCData (unsigned int frame = 0) const = 0;
virtual bool hasExif() const = 0;
/** @return a struct containing the date and time of the image */
virtual tm getDateTime (unsigned int frame = 0) const = 0;
virtual tm getDateTime() const = 0;
/** @return a timestamp containing the date and time of the image */
virtual time_t getDateTimeAsTS(unsigned int frame = 0) const = 0;
virtual time_t getDateTimeAsTS() const = 0;
/** @return the ISO of the image */
virtual int getISOSpeed (unsigned int frame = 0) const = 0;
virtual int getISOSpeed() const = 0;
/** @return the F number of the image */
virtual double getFNumber (unsigned int frame = 0) const = 0;
virtual double getFNumber() const = 0;
/** @return the focal length used at the exposure */
virtual double getFocalLen (unsigned int frame = 0) const = 0;
virtual double getFocalLen() const = 0;
/** @return the focal length in 35mm used at the exposure */
virtual double getFocalLen35mm (unsigned int frame = 0) const = 0;
virtual double getFocalLen35mm() const = 0;
/** @return the focus distance in meters, 0=unknown, 10000=infinity */
virtual float getFocusDist (unsigned int frame = 0) const = 0;
virtual float getFocusDist() const = 0;
/** @return the shutter speed */
virtual double getShutterSpeed (unsigned int frame = 0) const = 0;
virtual double getShutterSpeed() const = 0;
/** @return the exposure compensation */
virtual double getExpComp (unsigned int frame = 0) const = 0;
virtual double getExpComp() const = 0;
/** @return the maker of the camera */
virtual std::string getMake (unsigned int frame = 0) const = 0;
virtual std::string getMake() const = 0;
/** @return the model of the camera */
virtual std::string getModel (unsigned int frame = 0) const = 0;
virtual std::string getModel() const = 0;
std::string getCamera (unsigned int frame = 0) const
std::string getCamera() const
{
return getMake(frame) + " " + getModel(frame);
return getMake() + " " + getModel();
}
/** @return the lens on the camera */
virtual std::string getLens (unsigned int frame = 0) const = 0;
virtual std::string getLens() const = 0;
/** @return the orientation of the image */
virtual std::string getOrientation (unsigned int frame = 0) const = 0;
virtual std::string getOrientation() const = 0;
/** @return true if the file is a PixelShift shot (Pentax and Sony bodies) */
virtual bool getPixelShift () const = 0;
/** @return false: not an HDR file ; true: single or multi-frame HDR file (e.g. Pentax HDR raw file or 32 bit float DNG file or Log compressed) */
virtual bool getHDR (unsigned int frame = 0) const = 0;
virtual bool getHDR() const = 0;
/** @return false: not an HDR file ; true: single or multi-frame HDR file (e.g. Pentax HDR raw file or 32 bit float DNG file or Log compressed) */
virtual std::string getImageType (unsigned int frame) const = 0;
virtual std::string getImageType() const = 0;
/** @return the sample format based on MetaData */
virtual IIOSampleFormat getSampleFormat (unsigned int frame = 0) const = 0;
virtual IIOSampleFormat getSampleFormat() const = 0;
/** Functions to convert between floating point and string representation of shutter and aperture */
static std::string apertureToString (double aperture);
@@ -163,7 +140,9 @@ public:
* Use it only for raw files. In caseof jpgs and tiffs pass a NULL pointer.
* @param firstFrameOnly must be true to get the MetaData of the first frame only, e.g. for a PixelShift file.
* @return The metadata */
static FramesMetaData* fromFile (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml, bool firstFrameOnly = false);
static FramesMetaData* fromFile (const Glib::ustring& fname);
virtual Glib::ustring getFileName() const = 0;
};
/** This listener interface is used to indicate the progress of time consuming operations */