File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
python-bulk-images-resize Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import PIL
2
+ import os
3
+ import os .path
4
+ from PIL import Image
5
+
6
+ img_dir = r'C:/MyDocuments/roytuts/feature-images/temp/'
7
+
8
+ print ('Bulk images resizing started...' )
9
+
10
+ for img in os .listdir (img_dir ):
11
+ f_img = img_dir + img
12
+ f , e = os .path .splitext (img_dir + img )
13
+ img = Image .open (f_img )
14
+ img = img .resize ((1200 , 628 ))
15
+ #img.save(f + '_resized.jpg')
16
+ img .save (f_img )
17
+
18
+ print ('Bulk images resizing finished...' )
19
+
20
+ #from PIL import Image
21
+ #import os, sys
22
+
23
+ #img_dir = "C:/MyDocuments/roytuts/feature-images/resized-2/"
24
+ #dirs = os.listdir( img_dir )
25
+
26
+ #def resize_bulk_images():
27
+ # for img in dirs:
28
+ # if os.path.isfile(img_dir + img):
29
+ # im = Image.open(img_dir + img)
30
+ # f, e = os.path.splitext(img_dir + img)
31
+ # imResize = im.resize((1200, 628), Image.ANTIALIAS)
32
+ # imResize.save(f + '_resized.jpg', 'JPEG', quality=90)
33
+
34
+ #print('Bulk images resizing started...')
35
+ #resize_bulk_images()
36
+ #print('Bulk images resizing finished...')
Original file line number Diff line number Diff line change
1
+ You can go through the tutorial https://www.roytuts.com/how-to-resize-bulk-images-using-python/
You can’t perform that action at this time.
0 commit comments