Skip to content

Instantly share code, notes, and snippets.

@denstilwell
Created June 12, 2017 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denstilwell/8e01747f6899bac9d24194e20cbb2e8b to your computer and use it in GitHub Desktop.
Save denstilwell/8e01747f6899bac9d24194e20cbb2e8b to your computer and use it in GitHub Desktop.
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