batch image processing by Python
#!/usr/bin/python
import os
import re
from scipy import ndimage, misc
images = []
for root, dirnames, filenames in os.walk("."):
for filename in filenames:
if re.search("\.(jpg|jpeg|png)$", filename):
filepath = os.path.join(root, filename)
image = ndimage.imread(filepath, mode="L")
image_resized = misc.imresize(image, (256, 256))
misc.imsave(filepath, image_resized)
import os
import re
from scipy import ndimage, misc
images = []
for root, dirnames, filenames in os.walk("."):
for filename in filenames:
if re.search("\.(jpg|jpeg|png)$", filename):
filepath = os.path.join(root, filename)
image = ndimage.imread(filepath, mode="L")
image_resized = misc.imresize(image, (256, 256))
misc.imsave(filepath, image_resized)
댓글
댓글 쓰기