Fix the formatting of this script
- ID
792f304- date
2025-02-01 19:03:31+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
7deeac5- message
Fix the formatting of this script- changed files
1 file, 8 additions, 9 deletions
Changed files
images/squarify.py (1048) → images/squarify.py (1012)
diff --git a/images/squarify.py b/images/squarify.py
index 85c40bb..d594235 100755
--- a/images/squarify.py
+++ b/images/squarify.py
@@ -9,17 +9,17 @@ import sys
from PIL import Image
-if __name__ == '__main__':
+if __name__ == "__main__":
try:
path = Path(sys.argv[1])
except IndexError:
sys.exit(f"Usage: {__file__} IMAGE_PATH")
-
+
im = Image.open(path)
-
+
out_path = path.with_suffix(".square" + path.suffix)
assert out_path != path
-
+
if im.width == im.height:
print(path)
elif im.width > im.height:
@@ -27,7 +27,7 @@ if __name__ == '__main__':
upper = 0
right = im.width - (im.width - im.height) / 2
lower = im.height
-
+
crop_im = im.crop((left, upper, right, lower))
crop_im.save(out_path)
print(out_path)
@@ -36,10 +36,9 @@ if __name__ == '__main__':
upper = (im.height - im.width) / 2
right = im.width
lower = im.height - (im.height - im.width) / 2
-
+
crop_im = im.crop((left, upper, right, lower))
crop_im.save(out_path)
print(out_path)
-
-
- # main()
\ No newline at end of file
+
+ # main()