refinery
RAW file processor
|
Exif parser copied from dcraw.c. More...
#include <refinery/exif.h>
Public Member Functions | |
DcrawExifData (std::streambuf &istream) | |
Constructor. | |
DcrawExifData (FILE *f) | |
Constructor. | |
~DcrawExifData () | |
destructor. | |
const char * | mime_type () const |
Returns the detected MIME type of this image. | |
virtual bool | hasKey (const char *key) const |
True iff the Exif data contains the given key. | |
virtual std::string | getString (const char *key) const |
Returns the specified Exif value as a string. | |
virtual void | getBytes (const char *key, std::vector< byte > &outBytes) const |
Copies the specified Exif value into a byte-array. | |
virtual int | getInt (const char *key) const |
Returns the specified Exif value as an int. | |
virtual float | getFloat (const char *key) const |
Returns the specified Exif value as a float. |
Exif parser copied from dcraw.c.
Dcraw has impeccable camera-identifying code, but it doesn't store its in-memory data as Exif. For instance, it sometimes hard-codes the known width and height of a particular camera's sensor without looking at Exif tags, unlike refinery, which uses CameraData for all special cases. This class runs dcraw's calculations and then lets users access the results as if they were Exif data.
Example:
std::ifstream istream("image.NEF"); DcrawExifData exifData(istream); std::string model(exifData.getString("Exif.Image.Model")); std::cout << "Camera: " << model << std::endl;
refinery::DcrawExifData::DcrawExifData | ( | std::streambuf & | istream | ) |
Constructor.
The input stream will be forgotten when this method returns.
[in] | istream | Input stream to parse. |
refinery::DcrawExifData::DcrawExifData | ( | FILE * | f | ) |
Constructor.
The input stream will be forgotten when this method returns.
[in] | f | Input file pointer to parse. |
refinery::DcrawExifData::~DcrawExifData | ( | ) |
destructor.
virtual void refinery::DcrawExifData::getBytes | ( | const char * | key, |
std::vector< byte > & | outBytes | ||
) | const [virtual] |
Copies the specified Exif value into a byte-array.
Existing data will be erased.
This throws an error if the Exif data doesn't exist. Use hasKey() to verify that it does before calling this method.
[in] | key | Exif key, for instance "Exif.Nikon3.LinearizationTable". |
[out] | outBytes | Byte-array to fill. |
Implements refinery::ExifData.
virtual float refinery::DcrawExifData::getFloat | ( | const char * | key | ) | const [virtual] |
Returns the specified Exif value as a float.
This throws an error if the Exif data doesn't exist. Use hasKey() to verify that it does before calling this method.
[in] | key | Exif key, for instance "Exif.Image.XResolution". |
Implements refinery::ExifData.
virtual int refinery::DcrawExifData::getInt | ( | const char * | key | ) | const [virtual] |
Returns the specified Exif value as an int.
This throws an error if the Exif data doesn't exist. Use hasKey() to verify that it does before calling this method.
[in] | key | Exif key, for instance "Exif.Image.Orientation". |
Implements refinery::ExifData.
virtual std::string refinery::DcrawExifData::getString | ( | const char * | key | ) | const [virtual] |
Returns the specified Exif value as a string.
This throws an error if the Exif data doesn't exist. Use hasKey() to verify that it does before calling this method.
[in] | key | Exif key, for instance "Exif.Image.Model". |
Implements refinery::ExifData.
virtual bool refinery::DcrawExifData::hasKey | ( | const char * | key | ) | const [virtual] |
True iff the Exif data contains the given key.
[in] | key | Exif key, for instance "Exif.Image.Orientation". |
Implements refinery::ExifData.
const char* refinery::DcrawExifData::mime_type | ( | ) | const |
Returns the detected MIME type of this image.
This method is included as a convenience, since dcraw calculates the MIME type during parsing.