Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import PIL
from PIL import Image
import glob
import numpy as np
import tensorflow as tf
import os
import imghdr
# Load the data set
newwidth = 64
newhieght = 64
number = 0
path1 = '/data_set/temp_in' 
listing = os.listdir(path1)
for file in listing:   
if (imghdr.what('/data_set/temp_in/'+ file) == 'jpeg'):
print('jpeg')
number = number + 1
img = Image.open('/data_set/temp_in/'+ file)
img = img.resize((newwidth,newhieght ),
PIL.Image.ANTIALIAS)
img.save('/data_set/temp_out/s' + str(number) + '.jpg')
print(number)
print('all images resized')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment