website-2018-winter
website-2018-winter copied to clipboard
got some problem while running build_database.py using Windows
As tutorial says,for getting down-sized pics we should run build_database.py.However,a small problem occurred because Linux and Windows use different file directory separation mark.Function below should change filename.split('/')[-1]))
into filename.split('\\')[-1]))
while using Windows.
def resize_and_save(filename, output_dir, size=SIZE):
"""Resize the image contained in `filename` and save it to the `output_dir`"""
image = Image.open(filename)
# Use bilinear interpolation instead of the default "nearest neighbor" method
image = image.resize((size, size), Image.BILINEAR)
image.save(os.path.join(output_dir, filename.split('/')[-1]))
A better way would be to use os.path.basename
instead of filename.split('/')[-1]
.