From 1966fb7e138f0f930dbda9e799bb63835a81ed1c Mon Sep 17 00:00:00 2001 From: Youen Date: Sat, 31 Dec 2022 15:36:19 +0100 Subject: [PATCH] fixed image cropping bug (that was introducing an offset compared to the TechDraw view) --- ahb_raster_view.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ahb_raster_view.py b/ahb_raster_view.py index d135689..0738fbc 100644 --- a/ahb_raster_view.py +++ b/ahb_raster_view.py @@ -252,8 +252,9 @@ class RasterView: # Crop the image, which is also used to deduce the center of the source view original_size = composite_img.size - bg = Image.new(composite_img.mode, composite_img.size, '#ffffff') # fills an image with the background color - diff = ImageChops.difference(composite_img, bg) # diff between the actual image and the background color + diff_source_img = composite_img.split()[3] + bg = Image.new(diff_source_img.mode, diff_source_img.size, '#000000') # fills an image with the background color + diff = ImageChops.difference(diff_source_img, bg) # diff between the actual image and the background color bbox = diff.getbbox() # finds border size (non-black portion of the image) composite_img = composite_img.crop(bbox)