1
|
#include <exiv2/exiv2.hpp>
|
2
|
#include <iostream>
|
3
|
#include <iomanip>
|
4
|
#include <cassert>
|
5
|
#define EXIF_ORIENTATION_TAG 274
|
6
|
#define EXIF_CAMERA_MODEL_TAG 272
|
7
|
#define EXIF_DATETIME_TAG 306
|
8
|
extern "C" // start
|
9
|
{
|
10
|
#include "common_header.h"
|
11
|
#include "lip_image_processing.h"
|
12
|
#include "lip_image_processing_internal.h"
|
13
|
}
|
14
|
void exiv2(const char *jpg_filename, IMAGE *jpg_image)
|
15
|
{
|
16
|
Exiv2::ExifData::const_iterator exif_data_ptr, end;
|
17
|
Exiv2::Image::AutoPtr image;
|
18
|
|
19
|
image = Exiv2::ImageFactory::open(jpg_filename);
|
20
|
|
21
|
if(!image.get())
|
22
|
{
|
23
|
image_lib_program_error(__FILE__, __LINE__, __FUNC__,
|
24
|
"can't read <%s>", jpg_filename);
|
25
|
}
|
26
|
|
27
|
image->readMetadata();
|
28
|
Exiv2::ExifData &exifData = image->exifData();
|
29
|
|
30
|
if(exifData.empty())
|
31
|
{
|
32
|
image_lib_program_warning(__FILE__, __LINE__, __FUNC__,
|
33
|
"exifData is empty <%s>", jpg_filename);
|
34
|
return;
|
35
|
}
|
36
|
|
37
|
end = exifData.end();
|
38
|
|
39
|
for(exif_data_ptr = exifData.begin(); exif_data_ptr != end; exif_data_ptr++)
|
40
|
{
|
41
|
switch(exif_data_ptr->tag())
|
42
|
{
|
43
|
case EXIF_CAMERA_MODEL_TAG:
|
44
|
case EXIF_ORIENTATION_TAG:
|
45
|
case EXIF_DATETIME_TAG:
|
46
|
std::cout
|
47
|
<< std::setw(44)
|
48
|
<< std::setfill(' ')
|
49
|
<< std::left
|
50
|
<< exif_data_ptr->key()
|
51
|
<< " "
|
52
|
<< std::dec
|
53
|
<< exif_data_ptr->value()
|
54
|
<< "\n";
|
55
|
break;
|
56
|
|
57
|
default:
|
58
|
break;
|
59
|
}
|
60
|
}
|
61
|
|
62
|
for(exif_data_ptr = exifData.begin(); exif_data_ptr != end; exif_data_ptr++)
|
63
|
{
|
64
|
switch(exif_data_ptr->tag())
|
65
|
{
|
66
|
case EXIF_CAMERA_MODEL_TAG:
|
67
|
// !!! the following line is wrong !!!
|
68
|
//strncpy(jpg_image->CameraModel, (char *)(exif_data_ptr->value()), CAMERA_MODEL_STRING_LENGTH);
|
69
|
break;
|
70
|
|
71
|
case EXIF_ORIENTATION_TAG:
|
72
|
// !!! the following line is wrong !!!
|
73
|
//jpg_image->orientation = (int)(exif_data_ptr->value());
|
74
|
break;
|
75
|
|
76
|
case EXIF_DATETIME_TAG:
|
77
|
// !!! the following line is wrong !!!
|
78
|
//strncpy(jpg_image->DateTime, (char *)(exif_data_ptr->value()), DATETIME_STRING_LENGTH);
|
79
|
break;
|
80
|
|
81
|
default:
|
82
|
break;
|
83
|
}
|
84
|
}
|
85
|
}
|
86
|
|