From 8c58596fc0bf6c74ea399662f6d9730233730912 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Mon, 2 Oct 2023 09:40:03 -0400 Subject: [PATCH 1/3] use Pillow on server to resize crystal snapshot --- ispybLib.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ispybLib.py b/ispybLib.py index 4c78f2a5..796c9810 100644 --- a/ispybLib.py +++ b/ispybLib.py @@ -226,10 +226,13 @@ def insertResult(result,resultType,request,visitName,dc_id=None,xmlFileName=None daq_utils.take_crystal_picture(filename=jpegImagePrefix) jpegImageFilename = jpegImagePrefix+".jpg" jpegImageThumbFilename = jpegImagePrefix+"t.jpg" - node = db_lib.getBeamlineConfigParam(beamline,"adxvNode") - comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}resize.sh {jpegImageFilename} {jpegImageThumbFilename} 40% \"&" logger.info('resizing image: %s' % comm_s) - os.system(comm_s) + resizeRatio = 0.4 + fullSnapshot = Image.open(jpegImageFilename) + resizeWidth = fullSnapshot.width * resizeRatio + resizeHeight = fullSnapshot.height * resizeRatio + thumbSnapshot = fullSnapshot.resize((int(resizeWidth), int(resizeHeight))) + thumbSnapshot.save(jpegImageThumbFilename) seqNum = int(det_lib.detector_get_seqnum()) node = db_lib.getBeamlineConfigParam(beamline,"adxvNode") From 35717803e1c773201f7d2da8f5e3b7517446addc Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 3 Oct 2023 14:38:03 -0400 Subject: [PATCH 2/3] fix logging message - show both ratio and filename --- ispybLib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ispybLib.py b/ispybLib.py index 796c9810..19ed1e47 100644 --- a/ispybLib.py +++ b/ispybLib.py @@ -226,8 +226,8 @@ def insertResult(result,resultType,request,visitName,dc_id=None,xmlFileName=None daq_utils.take_crystal_picture(filename=jpegImagePrefix) jpegImageFilename = jpegImagePrefix+".jpg" jpegImageThumbFilename = jpegImagePrefix+"t.jpg" - logger.info('resizing image: %s' % comm_s) resizeRatio = 0.4 + logger.info(f'resizing image: ratio: {resizeRatio} filename: {jpegImageThumbFilename}') fullSnapshot = Image.open(jpegImageFilename) resizeWidth = fullSnapshot.width * resizeRatio resizeHeight = fullSnapshot.height * resizeRatio From d4827459d4370b173ce6f6aac7db6a91bd058393 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 3 Oct 2023 14:42:48 -0400 Subject: [PATCH 3/3] fix missing import --- ispybLib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ispybLib.py b/ispybLib.py index 19ed1e47..e1ec58c2 100644 --- a/ispybLib.py +++ b/ispybLib.py @@ -8,6 +8,7 @@ import db_lib import det_lib import time +from PIL import Image import logging logger = logging.getLogger(__name__)