libopenraw  0.3.7
dumputils.cpp
1 /*
2  * libopenraw - dumputils.cpp
3  *
4  * Copyright (C) 2007-2020 Hubert Figuière
5  * Copyright (C) 2008 Novell, Inc.
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <boost/format.hpp>
23 
24 #include "dumputils.hpp"
25 
27 {
28  switch(t) {
30  break;
32  return "Canon CR2";
33  break;
35  return "Canon CR3";
36  break;
38  return "Canon CRW";
39  break;
41  return "Nikon NEF";
42  break;
44  return "Nikon NRW";
45  break;
47  return "Minolta MRW";
48  break;
50  return "Sony ARW";
51  break;
53  return "Sony SR2";
54  break;
56  return "Adobe DNG";
57  break;
59  return "Olympus ORF";
60  break;
62  return "Pentax PEF";
63  break;
65  return "Epson ERF";
66  break;
68  return "Panasonic RAW";
69  break;
71  return "FujiFilm RAF";
72  break;
74  return "TIFF";
75  break;
77  return "GoPro GPR";
78  break;
79  }
80  return "Unknown";
81 }
82 
83 
84 void dump_file_info(std::ostream& out, ORRawFileRef rf, bool dev_mode)
85 {
86  or_rawfile_type fileType = or_rawfile_get_type(rf);
87  out << boost::format("\tType = %1% (%2%)\n")
88  % fileType % typeToString(fileType);
90  std::string typeId
91  = str(boost::format("%1%, %2%")
92  % OR_GET_FILE_TYPEID_VENDOR(fileTypeId)
93  % OR_GET_FILE_TYPEID_CAMERA(fileTypeId));
94  out << boost::format("\tType ID = %1%\n") % typeId;
96  if (fileType == OR_RAWFILE_TYPE_DNG) {
97  ORConstMetaValueRef original_value
98  = or_rawfile_get_metavalue(rf, META_NS_TIFF | DNG_TAG_ORIGINAL_RAW_FILE_NAME);
99  if (original_value) {
100  auto original = or_metavalue_get_string(original_value, 0);
101  if (original != nullptr) {
102  out << boost::format("\tConverted to DNG from '%1%'\n") % original;
103  }
104  }
105  }
106  if (vendorId != OR_GET_FILE_TYPEID_VENDOR(fileTypeId)) {
107  out <<
108  boost::format(
109  "\t*ERROR*: mismatched vendor id, got %1%\n")
110  % vendorId;
111  }
112 
114  = or_rawfile_get_metavalue(rf, META_NS_TIFF | EXIF_TAG_MAKE);
115  if (make) {
116  out << boost::format(dev_mode ?
117  "\tMake = \"%1%\"\n" : "\tMake = %1%\n")
118  % or_metavalue_get_string(make, 0);
119  }
120  ORConstMetaValueRef model
121  = or_rawfile_get_metavalue(rf, META_NS_TIFF | EXIF_TAG_MODEL);
122  if (model) {
123  out << boost::format(dev_mode ?
124  "\tModel = \"%1%\"\n" : "\tModel = %1%\n")
125  % or_metavalue_get_string(model, 0);
126  }
127  ORConstMetaValueRef uniqueCameraModel
129  | DNG_TAG_UNIQUE_CAMERA_MODEL);
130  if (uniqueCameraModel) {
131  out << boost::format("\tUnique Camera Model = %1%\n")
132  % or_metavalue_get_string(uniqueCameraModel, 0);
133  }
134 }
const struct _MetaValue * ORConstMetaValueRef
A const metadata value.
Definition: metadata.h:47
API_EXPORT const char * or_metavalue_get_string(ORConstMetaValueRef value, uint32_t idx)
Get the string out of the MetaValue.
Definition: metadata.cpp:39
@ META_NS_TIFF
Definition: metadata.h:52
#define OR_GET_FILE_TYPEID_CAMERA(ftypeid)
Get the camera from the or_rawfile_typeid.
Definition: consts.h:137
uint32_t or_rawfile_typeid
This is the type ID, a combination of vendor model It maps a specific camera. Only for the NATIVE fil...
Definition: consts.h:130
struct _RawFile * ORRawFileRef
RawFile reference.
Definition: types.h:30
or_rawfile_type
Types of RAW files.
Definition: consts.h:59
#define OR_GET_FILE_TYPEID_VENDOR(ftypeid)
Get the vendor from the or_rawfile_typeid.
Definition: consts.h:135
@ OR_RAWFILE_TYPE_MRW
Definition: consts.h:64
@ OR_RAWFILE_TYPE_DNG
Definition: consts.h:66
@ OR_RAWFILE_TYPE_GPR
Definition: consts.h:75
@ OR_RAWFILE_TYPE_TIFF
Definition: consts.h:70
@ OR_RAWFILE_TYPE_NRW
Definition: consts.h:71
@ OR_RAWFILE_TYPE_RAF
Definition: consts.h:73
@ OR_RAWFILE_TYPE_CRW
Definition: consts.h:62
@ OR_RAWFILE_TYPE_ERF
Definition: consts.h:69
@ OR_RAWFILE_TYPE_NEF
Definition: consts.h:63
@ OR_RAWFILE_TYPE_SR2
Definition: consts.h:76
@ OR_RAWFILE_TYPE_CR3
Definition: consts.h:74
@ OR_RAWFILE_TYPE_ARW
Definition: consts.h:65
@ OR_RAWFILE_TYPE_RW2
Definition: consts.h:72
@ OR_RAWFILE_TYPE_PEF
Definition: consts.h:68
@ OR_RAWFILE_TYPE_UNKNOWN
Definition: consts.h:60
@ OR_RAWFILE_TYPE_ORF
Definition: consts.h:67
@ OR_RAWFILE_TYPE_CR2
Definition: consts.h:61
API_EXPORT or_rawfile_typeid or_rawfile_get_vendorid(ORRawFileRef rawfile)
Return the type id to identify the vendor.
Definition: rawfile.cpp:105
API_EXPORT ORConstMetaValueRef or_rawfile_get_metavalue(ORRawFileRef rawfile, int32_t meta_index)
Get the metadata value.
Definition: rawfile.cpp:214
API_EXPORT or_rawfile_typeid or_rawfile_get_typeid(ORRawFileRef rawfile)
Return the type id to identify the exact file type.
Definition: rawfile.cpp:97
API_EXPORT or_rawfile_type or_rawfile_get_type(ORRawFileRef rawfile)
Get the RawFile type.
Definition: rawfile.cpp:89
void dump_file_info(std::ostream &out, ORRawFileRef rf, bool dev_mode)
Dump raw file info.
Definition: dumputils.cpp:84
std::string typeToString(or_rawfile_type t)
Return a string for the raw file type.
Definition: dumputils.cpp:26