Merge pull request #5325 from erjiang/embedded-ratings
Use ratings from image metadata
This commit is contained in:
@@ -24,12 +24,37 @@
|
||||
|
||||
#include "../rtengine/procparams.h"
|
||||
|
||||
CacheImageData::CacheImageData ()
|
||||
: md5(""), supported(false), format(FT_Invalid), rankOld(-1), inTrashOld(false), recentlySaved(false),
|
||||
timeValid(false), year(0), month(0), day(0), hour(0), min(0), sec(0), exifValid(false), frameCount(1),
|
||||
fnumber(0.0), shutter(0.0), focalLen(0.0), focalLen35mm(0.0), focusDist(0.f), iso(0), isHDR (false),
|
||||
isPixelShift (false), sensortype(rtengine::ST_NONE), sampleFormat(rtengine::IIOSF_UNKNOWN),
|
||||
redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0), rotate(0), thumbImgType(0)
|
||||
CacheImageData::CacheImageData() :
|
||||
supported(false),
|
||||
format(FT_Invalid),
|
||||
rankOld(-1),
|
||||
inTrashOld(false),
|
||||
recentlySaved(false),
|
||||
timeValid(false),
|
||||
year(0),
|
||||
month(0),
|
||||
day(0),
|
||||
hour(0),
|
||||
min(0),
|
||||
sec(0),
|
||||
exifValid(false),
|
||||
frameCount(1),
|
||||
fnumber(0.0),
|
||||
shutter(0.0),
|
||||
focalLen(0.0),
|
||||
focalLen35mm(0.0),
|
||||
focusDist(0.f),
|
||||
iso(0),
|
||||
rating(0),
|
||||
isHDR (false),
|
||||
isPixelShift (false),
|
||||
sensortype(rtengine::ST_NONE),
|
||||
sampleFormat(rtengine::IIOSF_UNKNOWN),
|
||||
redAWBMul(-1.0),
|
||||
greenAWBMul(-1.0),
|
||||
blueAWBMul(-1.0),
|
||||
rotate(0),
|
||||
thumbImgType(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,6 +91,10 @@ int CacheImageData::load (const Glib::ustring& fname)
|
||||
rankOld = keyFile.get_integer ("General", "Rank");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("General", "Rating")) {
|
||||
rating = keyFile.get_integer ("General", "Rating");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("General", "InTrash")) {
|
||||
inTrashOld = keyFile.get_boolean ("General", "InTrash");
|
||||
}
|
||||
@@ -227,6 +256,7 @@ int CacheImageData::save (const Glib::ustring& fname)
|
||||
keyFile.set_boolean ("General", "Supported", supported);
|
||||
keyFile.set_integer ("General", "Format", format);
|
||||
keyFile.set_boolean ("General", "RecentlySaved", recentlySaved);
|
||||
keyFile.set_integer ("General", "Rating", rating);
|
||||
|
||||
// remove the old implementation of Rank and InTrash from cache
|
||||
if (keyFile.has_key ("General", "Rank")) {
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
double focalLen, focalLen35mm;
|
||||
float focusDist;
|
||||
unsigned iso;
|
||||
int rating;
|
||||
bool isHDR;
|
||||
bool isPixelShift;
|
||||
int sensortype;
|
||||
@@ -108,6 +109,7 @@ public:
|
||||
std::string getModel (unsigned int frame = 0) const override { return camModel; }
|
||||
std::string getLens (unsigned int frame = 0) const override { return lens; }
|
||||
std::string getOrientation (unsigned int frame = 0) const override { return ""; } // TODO
|
||||
int getRating (unsigned int frame = 0) const override { return rating; } // FIXME-piotr : missing rating
|
||||
bool getPixelShift () const override { return isPixelShift; }
|
||||
bool getHDR (unsigned int frame = 0) const override { return isHDR; }
|
||||
std::string getImageType (unsigned int frame) const override { return isPixelShift ? "PS" : isHDR ? "HDR" : "STD"; }
|
||||
|
@@ -813,6 +813,7 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname, std::unique_ptr<rtengi
|
||||
cfs.lens = idata->getLens();
|
||||
cfs.camMake = idata->getMake();
|
||||
cfs.camModel = idata->getModel();
|
||||
cfs.rating = idata->getRating();
|
||||
|
||||
if (idata->getOrientation() == "Rotate 90 CW") {
|
||||
deg = 90;
|
||||
@@ -1005,15 +1006,22 @@ void Thumbnail::setFileName (const Glib::ustring &fn)
|
||||
|
||||
int Thumbnail::getRank () const
|
||||
{
|
||||
return pparams->rank;
|
||||
// prefer the user-set rank over the embedded Rating
|
||||
// pparams->rank == -1 means that there is no saved rank yet, so we should
|
||||
// next look for the embedded Rating metadata.
|
||||
if (pparams->rank != -1) {
|
||||
return pparams->rank;
|
||||
} else {
|
||||
return cfs.rating;
|
||||
}
|
||||
}
|
||||
|
||||
void Thumbnail::setRank (int rank)
|
||||
{
|
||||
if (pparams->rank != rank) {
|
||||
pparams->rank = rank;
|
||||
pparamsValid = true;
|
||||
}
|
||||
pparamsValid = true;
|
||||
}
|
||||
|
||||
int Thumbnail::getColorLabel () const
|
||||
|
Reference in New Issue
Block a user