@@ -411,13 +411,15 @@ cdef class RawPy:
411411 with nogil:
412412 self .p.recycle()
413413
414- def open_file (self , path ):
414+ def open_file (self , path , shot_select = 0 ):
415415 """
416416 Opens the given RAW image file. Should be followed by a call to :meth:`~rawpy.RawPy.unpack`.
417417
418418 .. NOTE:: This is a low-level method, consider using :func:`rawpy.imread` instead.
419419
420420 :param str path: The path to the RAW image.
421+ :param int shot_select: select which image to extract from RAW files that contain multiple images
422+ (e.g., Dual Pixel RAW). Default is 0 for the first/main image.
421423 """
422424 cdef wchar_t * wchars
423425 cdef Py_ssize_t wchars_len
@@ -433,14 +435,19 @@ cdef class RawPy:
433435 ELSE :
434436 res = self .p.open_file(path.encode(' UTF-8' ))
435437 self .handle_error(res)
438+ # Set shot_select after opening file
439+ cdef libraw_raw_unpack_params_t* rp = & self .p.imgdata.rawparams
440+ rp.shot_select = shot_select
436441
437- def open_buffer (self , fileobj ):
442+ def open_buffer (self , fileobj , shot_select = 0 ):
438443 """
439444 Opens the given RAW image file-like object. Should be followed by a call to :meth:`~rawpy.RawPy.unpack`.
440445
441446 .. NOTE:: This is a low-level method, consider using :func:`rawpy.imread` instead.
442447
443448 :param file fileobj: The file-like object.
449+ :param int shot_select: select which image to extract from RAW files that contain multiple images
450+ (e.g., Dual Pixel RAW). Default is 0 for the first/main image.
444451 """
445452 self .unpack_called = False
446453 self .unpack_thumb_called = False
@@ -451,6 +458,9 @@ cdef class RawPy:
451458 with nogil:
452459 e = self .p.open_buffer(buf, buf_len)
453460 self .handle_error(e)
461+ # Set shot_select after opening buffer
462+ cdef libraw_raw_unpack_params_t* rp = & self .p.imgdata.rawparams
463+ rp.shot_select = shot_select
454464
455465 def unpack (self ):
456466 """
@@ -971,10 +981,6 @@ cdef class RawPy:
971981 p.gamm[1 ] = params.gamm[1 ]
972982 p.aber[0 ] = params.aber[0 ]
973983 p.aber[2 ] = params.aber[1 ]
974-
975- # shot_select is in rawparams, not params
976- cdef libraw_raw_unpack_params_t* rp = & self .p.imgdata.rawparams
977- rp.shot_select = params.shot_select
978984
979985 cdef handle_error(self , int code):
980986 if code > 0 :
@@ -1122,7 +1128,7 @@ class Params(object):
11221128 bright = 1.0 , highlight_mode = HighlightMode.Clip,
11231129 exp_shift = None , exp_preserve_highlights = 0.0 , no_auto_scale = False ,
11241130 gamma = None , chromatic_aberration = None ,
1125- bad_pixels_path = None , shot_select = 0 ):
1131+ bad_pixels_path = None ):
11261132 """
11271133
11281134 If use_camera_wb and use_auto_wb are False and user_wb is None, then
@@ -1165,8 +1171,6 @@ class Params(object):
11651171 :param str bad_pixels_path: path to dcraw bad pixels file. Each bad pixel will be corrected using
11661172 the mean of the neighbor pixels. See the :mod:`rawpy.enhance` module
11671173 for alternative repair algorithms, e.g. using the median.
1168- :param int shot_select: select which image to extract from RAW files that contain multiple images
1169- (e.g., Dual Pixel RAW). Default is 0 for the first/main image.
11701174 """
11711175
11721176 if demosaic_algorithm:
@@ -1227,7 +1231,6 @@ class Params(object):
12271231 else :
12281232 self .aber = (1 , 1 )
12291233 self .bad_pixels = bad_pixels_path
1230- self .shot_select = shot_select
12311234
12321235cdef class processed_image_wrapper:
12331236 cdef RawPy raw
0 commit comments