aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2022-11-17 11:10:45 -0800
committerclarkzjw <[email protected]>2022-11-17 11:10:45 -0800
commit36b13e7d3de9af582a88a1a5b2a3c29be3d40d54 (patch)
tree1cefd6c0fe1c8762f2d7924dad8021e3d60edae4
parent60509a72b65f41d95729539a98aa7e595a96e24c (diff)
downloadSquare-36b13e7d3de9af582a88a1a5b2a3c29be3d40d54.tar.gz
+ update
-rw-r--r--exif.py2
-rwxr-xr-x[-rw-r--r--]square.py10
2 files changed, 2 insertions, 10 deletions
diff --git a/exif.py b/exif.py
index 15fd059..7ae3cc5 100644
--- a/exif.py
+++ b/exif.py
@@ -5,8 +5,6 @@ import sys
5 5
6 6
7def rename(month): 7def rename(month):
8 # base_directory = pathlib.Path("/mnt/nas/Photo/RAW/2022/")
9 # base_directory = pathlib.Path("/run/user/1000/kio-fuse-rQvVbo/smb/192.168.1.77/NAS/Photo/RAW/2022/")
10 base_directory = pathlib.Path("/mnt/c/Users/clarkzjw/Desktop/") 8 base_directory = pathlib.Path("/mnt/c/Users/clarkzjw/Desktop/")
11 directory = str(base_directory.joinpath(month).absolute()) + "/" 9 directory = str(base_directory.joinpath(month).absolute()) + "/"
12 10
diff --git a/square.py b/square.py
index fcc5fab..903e939 100644..100755
--- a/square.py
+++ b/square.py
@@ -18,7 +18,7 @@ def insta_size_padding(img):
18 padding_percentage = 0.02 18 padding_percentage = 0.02
19 length = max(w, h) 19 length = max(w, h)
20 padding = int(padding_percentage * length) 20 padding = int(padding_percentage * length)
21 new = Image.new(img.mode, (length + 2 * padding, length + 2 * padding), 0xeeeeee) 21 new = Image.new(img.mode, (length + 2 * padding, length + 2 * padding), 0xFAFAFA)
22 if h >= w: 22 if h >= w:
23 new.paste(img, (int((length + 2 * padding - w) / 2), padding)) 23 new.paste(img, (int((length + 2 * padding - w) / 2), padding))
24 else: 24 else:
@@ -41,8 +41,6 @@ def drop_shadow(image, offset=(5, 5), background=0xffffff, shadow=0x444444, bord
41 produce a more blurred shadow, but increase processing time. 41 produce a more blurred shadow, but increase processing time.
42 """ 42 """
43 43
44 # Create the backdrop image -- a box in the background colour with a
45 # shadow on it.
46 w, h = image.size 44 w, h = image.size
47 45
48 total_width = w + abs(offset[0]) + 2 * border 46 total_width = w + abs(offset[0]) + 2 * border
@@ -50,19 +48,15 @@ def drop_shadow(image, offset=(5, 5), background=0xffffff, shadow=0x444444, bord
50 back = Image.new(image.mode, (total_width, total_height), background) 48 back = Image.new(image.mode, (total_width, total_height), background)
51 shadow_image = Image.new(image.mode, (w, h), shadow) 49 shadow_image = Image.new(image.mode, (w, h), shadow)
52 50
53 # Place the shadow, taking into account the offset from the image
54 shadow_left = border + max(offset[0], 0) 51 shadow_left = border + max(offset[0], 0)
55 shadow_top = border + max(offset[1], 0) 52 shadow_top = border + max(offset[1], 0)
56 back.paste(shadow_image, (shadow_left, shadow_top)) 53 back.paste(shadow_image, (shadow_left, shadow_top))
57 54
58 # Apply the filter to blur the edges of the shadow. Since a small kernel
59 # is used, the filter must be applied repeatedly to get a decent blur.
60 n = 0 55 n = 0
61 while n < iterations: 56 while n < iterations:
62 back = back.filter(ImageFilter.BLUR) 57 back = back.filter(ImageFilter.BLUR)
63 n += 1 58 n += 1
64 59
65 # Paste the input image onto the shadow backdrop
66 image_left = border - min(offset[0], 0) 60 image_left = border - min(offset[0], 0)
67 image_top = border - min(offset[1], 0) 61 image_top = border - min(offset[1], 0)
68 back.paste(image, (image_left, image_top)) 62 back.paste(image, (image_left, image_top))
@@ -81,5 +75,5 @@ if __name__ == "__main__":
81 except Exception as e: 75 except Exception as e:
82 print(str(e)) 76 print(str(e))
83 continue 77 continue
84 result = insta_size_padding(drop_shadow(im, background=0xeeeeee, shadow=0x444444, offset=(20, 20))) 78 result = insta_size_no_padding(drop_shadow(im, background=0xFAFAFA, shadow=0x444444, offset=(20, 20)))
85 result.save("{}-square-shadow.{}".format(names[0], names[1]), quality=100) 79 result.save("{}-square-shadow.{}".format(names[0], names[1]), quality=100)
Powered by cgit v1.2.3 (git 2.41.0)