1
|
extern "C"
|
2
|
{
|
3
|
#include "common_header.h"
|
4
|
#include "lip_image_processing.h"
|
5
|
#include "lip_image_processing_internal.h"
|
6
|
}
|
7
|
void exiv2(const char *jpg_filename, IMAGE *jpg_image)
|
8
|
{
|
9
|
char data[256];
|
10
|
Exiv2::ExifData::const_iterator exif_data_ptr, begin, end;
|
11
|
Exiv2::Image::AutoPtr image;
|
12
|
|
13
|
image = Exiv2::ImageFactory::open(jpg_filename);
|
14
|
|
15
|
if(!image.get())
|
16
|
{
|
17
|
image_lib_program_error(__FILE__, __LINE__, __FUNC__,
|
18
|
"can't read <%s>", jpg_filename);
|
19
|
}
|
20
|
|
21
|
image->readMetadata();
|
22
|
Exiv2::ExifData &exifData = image->exifData();
|
23
|
|
24
|
if(exifData.empty())
|
25
|
{
|
26
|
image_lib_program_warning(__FILE__, __LINE__, __FUNC__,
|
27
|
"Exif data is empty in file <%s>",
|
28
|
strip_path_from_filename(jpg_filename));
|
29
|
return;
|
30
|
}
|
31
|
|
32
|
begin = exifData.begin();
|
33
|
end = exifData.end();
|
34
|
|
35
|
for(exif_data_ptr = begin; exif_data_ptr != end; exif_data_ptr++)
|
36
|
{
|
37
|
strncpy(data, exifData[exif_data_ptr->key()].toString().c_str(), 255);
|
38
|
|
39
|
switch(exif_data_ptr->tag())
|
40
|
{
|
41
|
case EXIF_CAMERA_MODEL_TAG:
|
42
|
strncpy(jpg_image->CameraModel, data, CAMERA_MODEL_STRING_LENGTH);
|
43
|
break;
|
44
|
|
45
|
case EXIF_ORIENTATION_TAG:
|
46
|
jpg_image->orientation = atoi(data);
|
47
|
break;
|
48
|
|
49
|
case EXIF_DATETIME_TAG:
|
50
|
strncpy(jpg_image->DateTime, data, DATETIME_STRING_LENGTH);
|
51
|
break;
|
52
|
|
53
|
default:
|
54
|
break;
|
55
|
}
|
56
|
}
|
57
|
|
58
|
printf
|
59
|
(
|
60
|
"%s\n\tcamera=\"%s\" datetime=\"%s\" orientation=%d\n",
|
61
|
jpg_filename,
|
62
|
jpg_image->CameraModel, jpg_image->DateTime,
|
63
|
jpg_image->orientation
|
64
|
);
|
65
|
}
|
66
|
|