From 0389ab760ae7bd7f36bc2302ae2e0d111bb8ea63 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 25 Jun 2025 16:52:23 +0000 Subject: [PATCH] Apply suggestions from code review of branch jpeg-capture-in-stacking Co-authored-by: Joe Knapper --- src/openflexure_microscope_server/things/camera/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openflexure_microscope_server/things/camera/__init__.py b/src/openflexure_microscope_server/things/camera/__init__.py index 31cfe0e3..14376e0f 100644 --- a/src/openflexure_microscope_server/things/camera/__init__.py +++ b/src/openflexure_microscope_server/things/camera/__init__.py @@ -248,6 +248,10 @@ class BaseCamera(Thing): if save_resolution is not None and image.size != save_resolution: image = image.resize(save_resolution, Image.BOX) try: + # Per PIL documentation, (https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#jpeg) + # there are two factors when saving a JPEG. subsampling affects the colour, quality the pixels + # subsampling = 0 disables subsampling of colour + # quality = 95 is the maximum recommended - above this, JPEG compression is disabled, file size increases and quality is barely or not affected image.save(jpeg_path, quality=95, subsampling=0) try: # Load EXIF metadata from image so it can be added to.