-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflowerThumbnail.py
More file actions
27 lines (20 loc) · 982 Bytes
/
flowerThumbnail.py
File metadata and controls
27 lines (20 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 11:53:57 2020
@author: CrisO
"""
import os
from PIL import Image
os.chdir("pathxy") #change directory to folder where results from jsonReader_flowers.py are stored
path = os.getcwd()
files = []
files = os.listdir(path) #get all filenames in folder as a list of strings
size= (150,200) #set size of thumbnail. I chose this size after some experimentation but one could choose other values
thumbnails = [] #initiate list for thumbnails
for file in files: #loop through all filenames in folder
image = Image.open(file) #get image with current filename
img = image.resize(size) #resize image with chosen values
thumbnails.append(img) #save resized image in list
os.chdir("pathxy") #change directory to folder where you want to save the resized images (Replace with real path)
for i in range(len(thumbnails)): #loop through all resized pictures
thumbnails[i].save(str(i) + "_thumbnail.jpeg") #save picture as jpeg