diff options
author | 秋 奈月 <43605695+akinazuki@users.noreply.github.com> | 2023-01-27 20:22:15 +0800 |
---|---|---|
committer | 秋 奈月 <43605695+akinazuki@users.noreply.github.com> | 2023-01-27 20:22:15 +0800 |
commit | c9fb3120ea8cf8e9e606d2ee6d723b8290aa1fe6 (patch) | |
tree | 0984b358c288aa3b73a4d0843a3c7363d1fc080a /Bio-punk/zipPhoto.py | |
parent | d142707a190be86d72d206c2ee1ada293fa4ff42 (diff) | |
download | Dress-c9fb3120ea8cf8e9e606d2ee6d723b8290aa1fe6.tar Dress-c9fb3120ea8cf8e9e606d2ee6d723b8290aa1fe6.tar.gz Dress-c9fb3120ea8cf8e9e606d2ee6d723b8290aa1fe6.tar.bz2 Dress-c9fb3120ea8cf8e9e606d2ee6d723b8290aa1fe6.zip |
archive
Diffstat (limited to 'Bio-punk/zipPhoto.py')
-rw-r--r-- | Bio-punk/zipPhoto.py | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/Bio-punk/zipPhoto.py b/Bio-punk/zipPhoto.py deleted file mode 100644 index 5036255..0000000 --- a/Bio-punk/zipPhoto.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -import cv2 -from os import listdir -from re import match -from re import I as flag -import numpy as np - -def resize_width(image, width=1200): - power = width * 1.0 / image.shape[1] - dim = (width, int(image.shape[0] * power)) - resized = cv2.resize(image, dim, interpolation=cv2.INTER_AREA) - return resized - -def zip_photo(filepath): - targetWidth = 1366 - image = cv2.imread(filepath) - if image.shape[0] > targetWidth: - image = resize_width(image=image, width = targetWidth) - cv2.imwrite("{}.jpg".format(filepath), image) - -dirpath = "." -for filename in listdir(dirpath): - ans = match("^(.*)[.]((png)|(bmp)|(jpg)|(jpeg))$", filename, flag) - if ans is not None: - print (filename) - zip_photo("{}/{}".format(dirpath, filename))
\ No newline at end of file |