Skip to content

Add shot_select support with set_unpack_params() method#276

Merged
letmaik merged 7 commits intomainfrom
copilot/support-shot-select-feature
Jan 28, 2026
Merged

Add shot_select support with set_unpack_params() method#276
letmaik merged 7 commits intomainfrom
copilot/support-shot-select-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 27, 2026

shot_select was incorrectly implemented as a postprocessing parameter. It must be set before unpacking since it controls which RAW image is decoded from multi-image files (e.g., Canon Dual Pixel RAW).

Changes

  • Added shot_select to imread(): High-level API takes shot_select parameter
  • Created set_unpack_params() method: New method in RawPy class for configuring unpack parameters
  • Set at correct time: imgdata.rawparams.shot_select is set after opening, before unpack() is called
  • Removed from postprocessing: Removed from Params class and apply_params()

API Change

Before:

with rawpy.imread('file.cr2') as raw:
    rgb = raw.postprocess(shot_select=1)  # Wrong: too late, after unpacking

After (high-level API):

with rawpy.imread('file.cr2', shot_select=1) as raw:
    rgb = raw.postprocess()  # Correct: set before unpacking

After (low-level API):

raw = rawpy.RawPy()
raw.open_file('file.cr2')
raw.set_unpack_params(shot_select=0)
raw.unpack()
rgb = raw.postprocess()
raw.close()

Technical Details

shot_select lives in imgdata.rawparams (unpacking stage), not imgdata.params (postprocessing stage). The new set_unpack_params() method provides a clean separation between file opening and unpack configuration, making the API more extensible for future unpack parameters. Setting it before unpacking allows LibRaw to properly select the image during decode and correctly error on nonexistent images.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can we support shot_select?</issue_title>
<issue_description>For instance a Canon RAW with Dual Pixel Raw enabled would have 2 RAW images in the file chosen by shot_select=0 or shot_select=1. Cameras like the 5D Mark IV or EOS R have that feature.</issue_description>

<agent_instructions>See https://www.libraw.org/docs/API-datastruct-eng.html for shot_select. Search for an example RAW image online that has two or more shots - we need to test it. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 27, 2026 23:04
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
…truct

Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for shot_select in Canon RAW files Add shot_select parameter for multi-image RAW files Jan 27, 2026
Copilot AI requested a review from letmaik January 27, 2026 23:15
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Copilot AI changed the title Add shot_select parameter for multi-image RAW files Move shot_select from postprocess to file opening Jan 27, 2026
…lect to open methods

Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Copilot AI changed the title Move shot_select from postprocess to file opening Add shot_select support with set_unpack_params() method Jan 27, 2026
Copilot AI requested a review from letmaik January 27, 2026 23:56
@letmaik letmaik marked this pull request as ready for review January 27, 2026 23:56
@letmaik letmaik merged commit 6ef164c into main Jan 28, 2026
110 checks passed
@letmaik letmaik deleted the copilot/support-shot-select-feature branch January 28, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can we support shot_select?

2 participants