1717import sys
1818import numpy as np
1919
20- _hdl = cdll .LoadLibrary (ctypes .util .find_library ("raw" ))
20+ # _hdl = cdll.LoadLibrary(ctypes.util.find_library("raw"))
21+ _hdl = cdll .LoadLibrary ("libraw.so.13.0.0" )
2122
2223enum_LibRaw_thumbnail_formats = c_int
2324time_t = c_long
@@ -26,10 +27,12 @@ class ph1_t(Structure):
2627 _fields_ = [
2728 ('format' , c_int ),
2829 ('key_off' , c_int ),
30+ ('tag_21a' , c_int ),
2931 ('t_black' , c_int ),
30- ('black_off' , c_int ),
3132 ('split_col' , c_int ),
32- ('tag_21a' , c_int ),
33+ ('black_col' , c_int ),
34+ ('split_row' , c_int ),
35+ ('black_row' , c_int ),
3336 ('tag_210' , c_float ),
3437 ]
3538
@@ -38,16 +41,19 @@ class libraw_iparams_t(Structure):
3841 _fields_ = [
3942 ('make' , c_char * 64 ),
4043 ('model' , c_char * 64 ),
44+ ('software' , c_char * 64 ), # 0.17+
4145 ('raw_count' , c_uint ),
4246 ('dng_version' , c_uint ),
4347 ('is_foveon' , c_uint ),
4448 ('colors' , c_int ),
4549 ('filters' , c_uint ),
46- # ('xtrans', c_char * 6 * 6), # 0.16+
50+ ('xtrans' , (c_char * 6 ) * 6 ), # 0.16+
51+ ('xtrans_abs' , (c_char * 6 ) * 6 ), # 0.17+
4752 ('cdesc' , c_char * 5 ),
53+ ('xmplen' , c_uint ), # 0.17+
54+ ('xmpdata' , c_char_p ), # 0.17+
4855 ]
4956
50-
5157class libraw_image_sizes_t (Structure ):
5258 _fields_ = [
5359 ('raw_height' , c_ushort ),
@@ -67,10 +73,18 @@ class libraw_image_sizes_t(Structure):
6773class libraw_dng_color_t (Structure ):
6874 _fields_ = [
6975 ('illuminant' , c_ushort ),
70- ('calibration ' , (c_float * 4 ) * 4 ),
71- ('colormatrix ' , (c_float * 3 ) * 4 ),
76+ ('_calibration ' , (c_float * 4 ) * 4 ),
77+ ('_colormatrix ' , (c_float * 4 ) * 3 ),
7278 ]
79+
80+ @property
81+ def colormatrix (self ):
82+ return _array_from_memory (self ._colormatrix , (4 , 3 ), np .float32 ).T
7383
84+ @property
85+ def calibration (self ):
86+ return _array_from_memory (self ._calibration , (4 , 4 ), np .float32 )
87+
7488class canon_makernotes_t (Structure ):
7589 _fields_ = [
7690 ('CanonColorDataVer' , c_int ),
@@ -82,23 +96,31 @@ class canon_makernotes_t(Structure):
8296class libraw_colordata_t (Structure ):
8397 _fields_ = [
8498 ('_curve' , c_ushort * 0x10000 ),
85- ('_cblack' , c_uint * 4 ),
99+ ('_cblack' , c_uint * 4102 ),
86100 ('black' , c_uint ),
87101 ('data_maximum' , c_uint ),
88102 ('maximum' , c_uint ),
89103 ('white' , c_ushort * 8 * 8 ),
90104 ('_cam_mul' , c_float * 4 ),
91105 ('_pre_mul' , c_float * 4 ),
92- ('_cmatrix' , c_float * 3 * 4 ),
93- ('_rgb_cam' , c_float * 3 * 4 ),
94- ('_cam_xyz' , c_float * 3 * 4 ),
106+ ('_cmatrix' , ( c_float * 4 ) * 3 ),
107+ ('_rgb_cam' , ( c_float * 4 ) * 3 ),
108+ ('_cam_xyz' , ( c_float * 3 ) * 4 ),
95109 ('phase_one_data' , ph1_t ),
96110 ('flash_used' , c_float ),
97111 ('canon_ev' , c_float ),
98112 ('model2' , c_char * 64 ),
99113 ('profile' , c_void_p ),
100114 ('profile_length' , c_uint ),
101- # ('black_stat', c_uint * 8), # 0.16+
115+ # 0.16+
116+ ('black_stat' , c_uint * 8 ),
117+ # 0.17+
118+ ('dng_color' , libraw_dng_color_t * 2 ),
119+ ('canon_makernotes' , canon_makernotes_t ),
120+ ('baseline_exposure' , c_float ),
121+ ('OlympusSensorCalibration' , c_int * 2 ),
122+ ('FujiExpoMidPointShift' , c_float ),
123+ ('digitalBack_color' , c_int ),
102124 ]
103125
104126 @property
@@ -127,7 +149,7 @@ def pre_mul(self):
127149
128150 @property
129151 def cblack (self ):
130- return _array_from_memory (self ._cblack , (4 ,), np .uint32 )
152+ return _array_from_memory (self ._cblack , (4102 ,), np .uint32 )
131153
132154class libraw_gps_info_t (Structure ):
133155 _fields_ = [
@@ -151,6 +173,7 @@ class libraw_imgother_t(Structure):
151173 ('timestamp' , time_t ),
152174 ('shot_order' , c_uint ),
153175 ('gpsdata' , c_uint * 32 ),
176+ ('parsed_gps' , libraw_gps_info_t ), # 0.17+
154177 ('desc' , c_char * 512 ),
155178 ('artist' , c_char * 64 ),
156179 ]
@@ -171,7 +194,7 @@ class libraw_internal_output_params_t(Structure):
171194 _fields_ = [
172195 ('mix_green' , c_uint ),
173196 ('raw_color' , c_uint ),
174- ('zero_is_bad' , c_uint ),
197+ ('zero_is_bad' , c_uint ), # 0.17+
175198 ('shrink' , c_ushort ),
176199 ('fuji_width' , c_ushort ),
177200 ]
@@ -184,7 +207,7 @@ class libraw_rawdata_t(Structure):
184207 ('color4_image' , POINTER (c_ushort * 4 )),
185208 ('color3_image' , POINTER (c_ushort * 3 )),
186209 ('ph1_black' , POINTER (c_short * 2 )),
187- # ('ph1_rblack', POINTER(c_short * 2)), # 0.17+
210+ ('ph1_rblack' , POINTER (c_short * 2 )), # 0.17+
188211 ('iparams' , libraw_iparams_t ),
189212 ('sizes' , libraw_image_sizes_t ),
190213 ('ioparams' , libraw_internal_output_params_t ),
@@ -223,7 +246,7 @@ class libraw_output_params_t(Structure):
223246 ('user_qual' , c_int ),
224247 ('user_black' , c_int ),
225248 ('user_cblack' , c_int * 4 ),
226- ('sony_arw2_hack' , c_int ),
249+ # ('sony_arw2_hack', c_int), # < 0.17
227250 ('user_sat' , c_int ),
228251 ('med_passes' , c_int ),
229252 ('auto_bright_thr' , c_float ),
@@ -253,10 +276,15 @@ class libraw_output_params_t(Structure):
253276 ('wf_deband_treshold' , c_float * 4 ),
254277 ('use_rawspeed' , c_int ),
255278 # 0.16+
256- # ('no_auto_scale', c_int),
257- # ('no_interpolation', c_int),
258- # ('straw_ycc', c_int),
259- # ('force_foveon_x3f', c_int),
279+ ('no_auto_scale' , c_int ),
280+ ('no_interpolation' , c_int ),
281+ ('sraw_ycc' , c_int ),
282+ ('force_foveon_x3f' , c_int ),
283+ # 0.17+
284+ ('x3f_flags' , c_int ),
285+ ('sony_arw2_options' , c_int ),
286+ ('sony_arw2_posterization_thr' , c_int ),
287+ ('coolscan_nef_gamma' , c_float ),
260288 ]
261289
262290class libraw_makernotes_lens_t (Structure ):
@@ -332,7 +360,7 @@ class libraw_data_t(Structure):
332360 ('_image' , POINTER (c_ushort * 4 )),
333361 ('sizes' , libraw_image_sizes_t ),
334362 ('idata' , libraw_iparams_t ),
335- # ('lens', libraw_lensinfo_t), # 0.17+
363+ ('lens' , libraw_lensinfo_t ), # 0.17+
336364 ('params' , libraw_output_params_t ),
337365 ('progress_flags' , c_uint ),
338366 ('process_warnings' , c_uint ),
0 commit comments