tools: port exp_combine to use gexiv2 instead of exiv2 directly

We already rely on gexiv2, and recent updates of exiv2 broke API this
commandline tool was reliant on.
parent 97b4e887
......@@ -38,9 +38,9 @@ noinst_PROGRAMS = introspect operation_reference detect_opencl gegl-tester opera
gegl_tester_SOURCES = \
gegl-tester.c
if HAVE_EXIV2
if HAVE_GEXIV2
noinst_PROGRAMS += exp_combine
exp_combine_SOURCES = exp_combine.cpp
exp_combine_LDADD = $(EXIV2_LIBS)
exp_combine_CXXFLAGS = $(AM_CFLAGS) $(EXIV2_CFLAGS)
exp_combine_LDADD = $(GEXIV2_LIBS)
exp_combine_CXXFLAGS = $(AM_CFLAGS) $(GEXIV2_CFLAGS)
endif
......@@ -8,8 +8,7 @@
#include <iostream>
#include <exiv2/image.hpp>
#include <exiv2/exif.hpp>
#include <gexiv2/gexiv2.h>
using namespace std;
......@@ -54,35 +53,32 @@ die:
static gfloat
expcombine_get_file_ev (const gchar *path)
{
/* Open the file and read in the metadata */
Exiv2::Image::AutoPtr image;
try
{
image = Exiv2::ImageFactory::open (path);
image->readMetadata ();
}
catch (Exiv2::Error ex)
{
g_print ("Error: unable to read metadata from path: '%s'\n", path);
exit (EXIT_FAILURE);
}
GError *error = NULL;
GExiv2Metadata *e2m = gexiv2_metadata_new ();
gfloat time, aperture, gain = 1.0f;
Exiv2::ExifData &exifData = image->exifData ();
if (exifData.empty ())
return NAN;
gexiv2_metadata_open_path (e2m, path, &error);
if (error)
{
g_warning ("%s", error->message);
exit (EXIT_FAILURE);
}
/* Calculate the APEX brightness / EV */
gfloat time, aperture, gain = 1.0f;
time = exifData["Exif.Photo.ExposureTime"].value().toFloat();
aperture = exifData["Exif.Photo.FNumber" ].value().toFloat();
{
gint nom, den;
gexiv2_metadata_get_exposure_time (e2m, &nom, &den);
time = nom * 1.0f / den;
}
aperture = gexiv2_metadata_get_fnumber (e2m);
/* iso */
try
if (gexiv2_metadata_has_tag (e2m, "Exif.Image.ISOSpeedRatings"))
{
gain = exifData["Exif.Photo.ISOSpeedRatings"].value().toLong() / 100.0f;
gain = gexiv2_metadata_get_iso_speed (e2m) / 100.0f;
}
catch (Exiv2::Error ex)
else
{
// Assume ISO is set at 100. It's reasonably likely that the ISO is the
// same across all images anyway, and for our purposes the relative
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment