Skip to content

Commit fb71b88

Browse files
committed
Fix saving lores YUV420 images as JPEG
A plain typo had broken this. Also extend tests/yuv_capture.py to test this case. Signed-off-by: David Plowman <[email protected]>
1 parent ebf7896 commit fb71b88

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

picamera2/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def save(self, name: str, file_output: Any, format: Optional[str] = None,
225225
if (config['format'] == 'YUV420' or (self.FASTER_JPEG and config['format'] != "MJPEG")) and \
226226
self.picam2.helpers._get_format_str(file_output, format) in ('jpg', 'jpeg'):
227227
quality = self.picam2.options.get("quality", 90)
228-
with MappedArray(self, 'main') as m:
228+
with MappedArray(self, name) as m:
229229
format = self.config[name]["format"]
230230
if format == 'YUV420':
231231
width, height = self.config[name]['size']

tests/yuv_capture.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
time.sleep(5)
1414
picam2.stop_recording()
1515

16-
still_config = picam2.create_still_configuration({"format": "YUV420"})
16+
lores = {"size": (640, 480), "format": "YUV420"}
17+
still_config = picam2.create_still_configuration({"format": "YUV420"}, lores=lores)
1718
picam2.configure(still_config)
1819
picam2.start()
1920

2021
time.sleep(2)
2122
picam2.capture_file("test.jpg")
23+
24+
# Also make sure the lores works - a typo had broken this case
25+
picam2.capture_file("lores.jpg", "lores")

0 commit comments

Comments
 (0)