test: region-sharpness.py and the Koldflux Blur background tool, python 3.10.18, Pillow, numpy, 2026-11-24 published: python3 region-sharpness.py photo.jpg 150 60 400 300 command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/sleeping-dog.jpg 150 60 400 300 (main: dog photo, background corner before blur) exit=0 edge: case run: main: dog photo, background corner before blur output: sleeping-dog.jpg rect 150,60 400x300 sharpness 24.41 published: python3 region-sharpness.py photo-blurred.png 150 60 400 300 command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py out/sleeping-dog-s40.png 150 60 400 300 (main: same box after the tool at strength 40) exit=0 edge: case run: main: same box after the tool at strength 40 output: sleeping-dog-s40.png rect 150,60 400x300 sharpness 0.83 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py out/sleeping-dog-s0.png 150 60 400 300 (control: strength 0 must equal the input) exit=0 edge: case run: control: strength 0 must equal the input output: sleeping-dog-s0.png rect 150,60 400x300 sharpness 24.41 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/sleeping-dog.jpg 780 650 420 400 (edge: the subject box (should barely change)) exit=0 edge: case run: edge: the subject box (should barely change) output: sleeping-dog.jpg rect 780,650 420x400 sharpness 184.11 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py edge/missing.jpg 0 0 50 50 (edge: missing file) exit=1 edge: case run: edge: missing file output: error: file not found: edge/missing.jpg published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py edge/empty.jpg 0 0 50 50 (edge: empty file) exit=1 edge: case run: edge: empty file output: error: file is empty: edge/empty.jpg published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py edge/notimage.jpg 0 0 50 50 (edge: text file named .jpg) exit=1 edge: case run: edge: text file named .jpg output: error: not a picture Pillow can read: edge/notimage.jpg published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/sleeping-dog.jpg 0 0 2 2 (edge: rectangle smaller than 3x3) exit=1 edge: case run: edge: rectangle smaller than 3x3 output: error: the rectangle must be at least 3 x 3 pixels published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/sleeping-dog.jpg 1900 0 400 300 (edge: rectangle outside the picture) exit=1 edge: case run: edge: rectangle outside the picture output: error: the rectangle leaves the picture (2000 x 1321 px) published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/sleeping-dog.jpg ten 0 50 50 (edge: a coordinate that is not a number) exit=1 edge: case run: edge: a coordinate that is not a number output: error: x, y, width and height must be whole numbers of pixels published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/rot6.jpg 0 0 1500 1900 (edge: phone JPEG with EXIF orientation 6 (the dog photo stored 2000 x 1321 with the tag; the tool shows it as 1321 x 2000)) exit=1 edge: case run: edge: phone JPEG with EXIF orientation 6 (the dog photo stored 2000 x 1321 with the tag; the tool shows it as 1321 x 2000) output: error: the rectangle leaves the picture (2000 x 1321 px) published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/cat-grass.jpg 0 400 600 700 (edge: cat body box, original) exit=0 edge: case run: edge: cat body box, original output: cat-grass.jpg rect 0,400 600x700 sharpness 7.04 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py out/cat-grass-s40.png 0 400 600 700 (edge: cat body box, strength 40 (0.80 / 7.04 = 11.4%)) exit=0 edge: case run: edge: cat body box, strength 40 (0.80 / 7.04 = 11.4%) output: cat-grass-s40.png rect 0,400 600x700 sharpness 0.80 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py in/cat-grass.jpg 400 750 400 300 (edge: cat chin and whiskers box, original) exit=0 edge: case run: edge: cat chin and whiskers box, original output: cat-grass.jpg rect 400,750 400x300 sharpness 56.99 published: python3 region-sharpness.py photo.jpg X Y WIDTH HEIGHT command as run: /opt/homebrew/bin/python3.10 -I region-sharpness.py out/cat-grass-s40.png 400 750 400 300 (edge: cat chin and whiskers box, strength 40 (9.72 / 56.99 = 17.1%)) exit=0 edge: case run: edge: cat chin and whiskers box, strength 40 (9.72 / 56.99 = 17.1%) output: cat-grass-s40.png rect 400,750 400x300 sharpness 9.72