Skip to content

Commit

Permalink
Replace exif_data defaults with None
Browse files Browse the repository at this point in the history
  • Loading branch information
Amudtogal committed Aug 29, 2023
1 parent 459e230 commit e32a407
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions picamera2/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ def dispatch_functions(self, functions, wait, signal_function=None, immediate=Fa
self._run_process_requests()
return job.get_result() if wait else job

def capture_file_(self, file_output, name: str, format=None, exif_data={}) -> dict:
def capture_file_(self, file_output, name: str, format=None, exif_data=None) -> dict:
if not self.completed_requests:
return (False, None)
request = self.completed_requests.pop(0)
Expand All @@ -1222,7 +1222,7 @@ def capture_file(
format=None,
wait=None,
signal_function=None,
exif_data={}) -> dict:
exif_data=None) -> dict:
"""Capture an image to a file in the current camera mode.
Return the metadata for the frame captured.
Expand All @@ -1246,7 +1246,7 @@ def switch_mode(self, camera_config, wait=None, signal_function=None):
return self.dispatch_functions(functions, wait, signal_function, immediate=True)

def switch_mode_and_capture_file(self, camera_config, file_output, name="main", format=None,
wait=None, signal_function=None, exif_data={}):
wait=None, signal_function=None, exif_data=None):
"""Switch the camera into a new (capture) mode, capture an image to file.
Then return back to the initial camera mode.
Expand All @@ -1265,7 +1265,7 @@ def capture_and_switch_back_(self, file_output, preview_config, format, exif_dat

functions = [partial(self.switch_mode_, camera_config),
partial(capture_and_switch_back_, self, file_output, preview_config, format,
exif_data=exif_data})]
exif_data=exif_data)]
return self.dispatch_functions(functions, wait, signal_function, immediate=True)

def switch_mode_and_capture_request(self, camera_config, wait=None, signal_function=None):
Expand Down Expand Up @@ -1629,7 +1629,7 @@ def set_overlay(self, overlay) -> None:
def start_and_capture_files(self, name: str = "image{:03d}.jpg",
initial_delay=1, preview_mode="preview",
capture_mode="still", num_files=1, delay=1,
show_preview=True, exif_data={}):
show_preview=True, exif_data=None):
"""This function makes capturing multiple images more convenient.
Should only be used in command line line applications (not from a Qt application, for example).
Expand Down
9 changes: 6 additions & 3 deletions picamera2/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ def make_image(self, name, width=None, height=None):
"""Make a PIL image from the named stream's buffer."""
return self.picam2.helpers.make_image(self.make_buffer(name), self.config[name], width, height)

def save(self, name, file_output, format=None, exif_data={}):
def save(self, name, file_output, format=None, exif_data=None):
"""Save a JPEG or PNG image of the named stream's buffer.
exif_data - dictionary containing user defined exif data (based on `piexif`). This will
overwrite existing exif information generated by picamera2.
"""
return self.picam2.helpers.save(self.make_image(name), self.get_metadata(), file_output, format)
return self.picam2.helpers.save(self.make_image(name), self.get_metadata(), file_output,
format, exif_data)

def save_dng(self, filename, name="raw"):
"""Save a DNG RAW image of the raw stream's buffer."""
Expand Down Expand Up @@ -244,12 +245,14 @@ def make_image(self, buffer, config, width=None, height=None):
pil_img = pil_img.resize((width, height))
return pil_img

def save(self, img, metadata, file_output, format=None, exif_data={}):
def save(self, img, metadata, file_output, format=None, exif_data=None):
"""Save a JPEG or PNG image of the named stream's buffer.
exif_data - dictionary containing user defined exif data (based on `piexif`). This will
overwrite existing exif information generated by picamera2.
"""
if exif_data is None:
exif_data = {}
# This is probably a hideously expensive way to do a capture.
start_time = time.monotonic()
exif = b''
Expand Down

0 comments on commit e32a407

Please sign in to comment.