diff options
author | bio-punk <cory@hnu.edu.cn> | 2019-01-24 20:41:13 +0800 |
---|---|---|
committer | bio-punk <cory@hnu.edu.cn> | 2019-01-24 20:42:14 +0800 |
commit | 9204d28650c86fb3bbc48f66b316a0fa4ba234db (patch) | |
tree | 038d712bc389d334b6399168ff99a05a60ea1a43 /Bio-punk | |
parent | fd5f277bd7cb5d563d902d197d9ea01ce181bed5 (diff) | |
download | Dress-9204d28650c86fb3bbc48f66b316a0fa4ba234db.tar Dress-9204d28650c86fb3bbc48f66b316a0fa4ba234db.tar.gz Dress-9204d28650c86fb3bbc48f66b316a0fa4ba234db.tar.bz2 Dress-9204d28650c86fb3bbc48f66b316a0fa4ba234db.zip |
用python和opencv写了个压缩图片的,图片压缩到1366的jpg格式
压缩了原来的照片
Diffstat (limited to 'Bio-punk')
-rw-r--r-- | Bio-punk/.gitignore | 2 | ||||
-rw-r--r-- | Bio-punk/20190124143731.bmp | bin | 2665386 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124143731.bmp.jpg | bin | 0 -> 81733 bytes | |||
-rw-r--r-- | Bio-punk/20190124143818.bmp | bin | 5499990 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124143818.bmp.jpg | bin | 0 -> 343535 bytes | |||
-rw-r--r-- | Bio-punk/20190124143909.png | bin | 827680 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124143909.png.jpg | bin | 0 -> 157665 bytes | |||
-rw-r--r-- | Bio-punk/20190124143959.bmp | bin | 649566 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124143959.bmp.jpg | bin | 0 -> 46306 bytes | |||
-rw-r--r-- | Bio-punk/20190124144017.bmp | bin | 1109574 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144017.bmp.jpg | bin | 0 -> 100097 bytes | |||
-rw-r--r-- | Bio-punk/20190124144201.bmp | bin | 6748950 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144201.bmp.jpg | bin | 0 -> 555930 bytes | |||
-rw-r--r-- | Bio-punk/20190124144332.bmp | bin | 2868534 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144332.bmp.jpg | bin | 0 -> 160194 bytes | |||
-rw-r--r-- | Bio-punk/20190124144351.bmp | bin | 3674934 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144351.bmp.jpg | bin | 0 -> 254696 bytes | |||
-rw-r--r-- | Bio-punk/20190124144638.png | bin | 746172 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144638.png.jpg | bin | 0 -> 180264 bytes | |||
-rw-r--r-- | Bio-punk/20190124144705.png | bin | 902963 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144705.png.jpg | bin | 0 -> 213113 bytes | |||
-rw-r--r-- | Bio-punk/20190124144740.png | bin | 923246 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144740.png.jpg | bin | 0 -> 242458 bytes | |||
-rw-r--r-- | Bio-punk/20190124144824.png | bin | 1608723 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144824.png.jpg | bin | 0 -> 605190 bytes | |||
-rw-r--r-- | Bio-punk/20190124144856.png | bin | 1319044 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144856.png.jpg | bin | 0 -> 250894 bytes | |||
-rw-r--r-- | Bio-punk/20190124144925.png | bin | 1132964 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124144925.png.jpg | bin | 0 -> 428759 bytes | |||
-rw-r--r-- | Bio-punk/20190124145008.bmp | bin | 2051862 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124145008.bmp.jpg | bin | 0 -> 155785 bytes | |||
-rw-r--r-- | Bio-punk/20190124145059.png | bin | 775895 -> 0 bytes | |||
-rw-r--r-- | Bio-punk/20190124145059.png.jpg | bin | 0 -> 178329 bytes | |||
-rw-r--r-- | Bio-punk/zipPhoto.py | 27 |
34 files changed, 29 insertions, 0 deletions
diff --git a/Bio-punk/.gitignore b/Bio-punk/.gitignore new file mode 100644 index 0000000..39ba4e8 --- /dev/null +++ b/Bio-punk/.gitignore @@ -0,0 +1,2 @@ +/*.bmp +/*.png diff --git a/Bio-punk/20190124143731.bmp b/Bio-punk/20190124143731.bmp Binary files differdeleted file mode 100644 index 4690e4d..0000000 --- a/Bio-punk/20190124143731.bmp +++ /dev/null diff --git a/Bio-punk/20190124143731.bmp.jpg b/Bio-punk/20190124143731.bmp.jpg Binary files differnew file mode 100644 index 0000000..949125e --- /dev/null +++ b/Bio-punk/20190124143731.bmp.jpg diff --git a/Bio-punk/20190124143818.bmp b/Bio-punk/20190124143818.bmp Binary files differdeleted file mode 100644 index 20f0f8e..0000000 --- a/Bio-punk/20190124143818.bmp +++ /dev/null diff --git a/Bio-punk/20190124143818.bmp.jpg b/Bio-punk/20190124143818.bmp.jpg Binary files differnew file mode 100644 index 0000000..275a9bd --- /dev/null +++ b/Bio-punk/20190124143818.bmp.jpg diff --git a/Bio-punk/20190124143909.png b/Bio-punk/20190124143909.png Binary files differdeleted file mode 100644 index 440c7ba..0000000 --- a/Bio-punk/20190124143909.png +++ /dev/null diff --git a/Bio-punk/20190124143909.png.jpg b/Bio-punk/20190124143909.png.jpg Binary files differnew file mode 100644 index 0000000..d6d7104 --- /dev/null +++ b/Bio-punk/20190124143909.png.jpg diff --git a/Bio-punk/20190124143959.bmp b/Bio-punk/20190124143959.bmp Binary files differdeleted file mode 100644 index 3c937e9..0000000 --- a/Bio-punk/20190124143959.bmp +++ /dev/null diff --git a/Bio-punk/20190124143959.bmp.jpg b/Bio-punk/20190124143959.bmp.jpg Binary files differnew file mode 100644 index 0000000..13cfe04 --- /dev/null +++ b/Bio-punk/20190124143959.bmp.jpg diff --git a/Bio-punk/20190124144017.bmp b/Bio-punk/20190124144017.bmp Binary files differdeleted file mode 100644 index c1321e9..0000000 --- a/Bio-punk/20190124144017.bmp +++ /dev/null diff --git a/Bio-punk/20190124144017.bmp.jpg b/Bio-punk/20190124144017.bmp.jpg Binary files differnew file mode 100644 index 0000000..366df66 --- /dev/null +++ b/Bio-punk/20190124144017.bmp.jpg diff --git a/Bio-punk/20190124144201.bmp b/Bio-punk/20190124144201.bmp Binary files differdeleted file mode 100644 index b97a025..0000000 --- a/Bio-punk/20190124144201.bmp +++ /dev/null diff --git a/Bio-punk/20190124144201.bmp.jpg b/Bio-punk/20190124144201.bmp.jpg Binary files differnew file mode 100644 index 0000000..92d2dca --- /dev/null +++ b/Bio-punk/20190124144201.bmp.jpg diff --git a/Bio-punk/20190124144332.bmp b/Bio-punk/20190124144332.bmp Binary files differdeleted file mode 100644 index f08fef5..0000000 --- a/Bio-punk/20190124144332.bmp +++ /dev/null diff --git a/Bio-punk/20190124144332.bmp.jpg b/Bio-punk/20190124144332.bmp.jpg Binary files differnew file mode 100644 index 0000000..8540d76 --- /dev/null +++ b/Bio-punk/20190124144332.bmp.jpg diff --git a/Bio-punk/20190124144351.bmp b/Bio-punk/20190124144351.bmp Binary files differdeleted file mode 100644 index 51a1fe8..0000000 --- a/Bio-punk/20190124144351.bmp +++ /dev/null diff --git a/Bio-punk/20190124144351.bmp.jpg b/Bio-punk/20190124144351.bmp.jpg Binary files differnew file mode 100644 index 0000000..48f130c --- /dev/null +++ b/Bio-punk/20190124144351.bmp.jpg diff --git a/Bio-punk/20190124144638.png b/Bio-punk/20190124144638.png Binary files differdeleted file mode 100644 index 4629c6b..0000000 --- a/Bio-punk/20190124144638.png +++ /dev/null diff --git a/Bio-punk/20190124144638.png.jpg b/Bio-punk/20190124144638.png.jpg Binary files differnew file mode 100644 index 0000000..f3de04b --- /dev/null +++ b/Bio-punk/20190124144638.png.jpg diff --git a/Bio-punk/20190124144705.png b/Bio-punk/20190124144705.png Binary files differdeleted file mode 100644 index c79c496..0000000 --- a/Bio-punk/20190124144705.png +++ /dev/null diff --git a/Bio-punk/20190124144705.png.jpg b/Bio-punk/20190124144705.png.jpg Binary files differnew file mode 100644 index 0000000..bd15086 --- /dev/null +++ b/Bio-punk/20190124144705.png.jpg diff --git a/Bio-punk/20190124144740.png b/Bio-punk/20190124144740.png Binary files differdeleted file mode 100644 index a2154c5..0000000 --- a/Bio-punk/20190124144740.png +++ /dev/null diff --git a/Bio-punk/20190124144740.png.jpg b/Bio-punk/20190124144740.png.jpg Binary files differnew file mode 100644 index 0000000..9fd6d3b --- /dev/null +++ b/Bio-punk/20190124144740.png.jpg diff --git a/Bio-punk/20190124144824.png b/Bio-punk/20190124144824.png Binary files differdeleted file mode 100644 index 1681e6a..0000000 --- a/Bio-punk/20190124144824.png +++ /dev/null diff --git a/Bio-punk/20190124144824.png.jpg b/Bio-punk/20190124144824.png.jpg Binary files differnew file mode 100644 index 0000000..0e58198 --- /dev/null +++ b/Bio-punk/20190124144824.png.jpg diff --git a/Bio-punk/20190124144856.png b/Bio-punk/20190124144856.png Binary files differdeleted file mode 100644 index d2cd119..0000000 --- a/Bio-punk/20190124144856.png +++ /dev/null diff --git a/Bio-punk/20190124144856.png.jpg b/Bio-punk/20190124144856.png.jpg Binary files differnew file mode 100644 index 0000000..1b190c9 --- /dev/null +++ b/Bio-punk/20190124144856.png.jpg diff --git a/Bio-punk/20190124144925.png b/Bio-punk/20190124144925.png Binary files differdeleted file mode 100644 index 1a8f62d..0000000 --- a/Bio-punk/20190124144925.png +++ /dev/null diff --git a/Bio-punk/20190124144925.png.jpg b/Bio-punk/20190124144925.png.jpg Binary files differnew file mode 100644 index 0000000..53dbea6 --- /dev/null +++ b/Bio-punk/20190124144925.png.jpg diff --git a/Bio-punk/20190124145008.bmp b/Bio-punk/20190124145008.bmp Binary files differdeleted file mode 100644 index 26545cc..0000000 --- a/Bio-punk/20190124145008.bmp +++ /dev/null diff --git a/Bio-punk/20190124145008.bmp.jpg b/Bio-punk/20190124145008.bmp.jpg Binary files differnew file mode 100644 index 0000000..c338279 --- /dev/null +++ b/Bio-punk/20190124145008.bmp.jpg diff --git a/Bio-punk/20190124145059.png b/Bio-punk/20190124145059.png Binary files differdeleted file mode 100644 index 1368b8c..0000000 --- a/Bio-punk/20190124145059.png +++ /dev/null diff --git a/Bio-punk/20190124145059.png.jpg b/Bio-punk/20190124145059.png.jpg Binary files differnew file mode 100644 index 0000000..4727220 --- /dev/null +++ b/Bio-punk/20190124145059.png.jpg diff --git a/Bio-punk/zipPhoto.py b/Bio-punk/zipPhoto.py new file mode 100644 index 0000000..5036255 --- /dev/null +++ b/Bio-punk/zipPhoto.py @@ -0,0 +1,27 @@ +# -*- 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 |