Browse Source

fixed image cropping bug (that was introducing an offset compared to the TechDraw view)

dev/better-annotations
Youen 2 years ago
parent
commit
1966fb7e13
  1. 5
      ahb_raster_view.py

5
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 # Crop the image, which is also used to deduce the center of the source view
original_size = composite_img.size original_size = composite_img.size
bg = Image.new(composite_img.mode, composite_img.size, '#ffffff') # fills an image with the background color diff_source_img = composite_img.split()[3]
diff = ImageChops.difference(composite_img, bg) # diff between the actual image and the background color 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) bbox = diff.getbbox() # finds border size (non-black portion of the image)
composite_img = composite_img.crop(bbox) composite_img = composite_img.crop(bbox)

Loading…
Cancel
Save