diff --git a/image/management/commands/generate_daymaps.py b/image/management/commands/generate_daymaps.py index d022885..500f3ca 100644 --- a/image/management/commands/generate_daymaps.py +++ b/image/management/commands/generate_daymaps.py @@ -68,18 +68,23 @@ def handle(self, *args, **options): im_max.putpixel(pos, color_max) # All done, save - dirpath = os.path.join(TIMELAPSE_DIR, APP_DIR, 'daymaps') - im_center.save(os.path.join(dirpath, 'center_raw.png')) - im_mean.save(os.path.join(dirpath, 'mean_raw.png')) - im_median.save(os.path.join(dirpath, 'median_raw.png')) - im_min.save(os.path.join(dirpath, 'min_raw.png')) - im_max.save(os.path.join(dirpath, 'max_raw.png')) + imagepath = os.path.join(TIMELAPSE_DIR, APP_DIR, 'daymaps') + + # Make directory if it doesn't exist + if not os.path.exists(imagepath): + os.makedirs(imagepath) + + im_center.save(os.path.join(imagepath, 'center_raw.png')) + im_mean.save(os.path.join(imagepath, 'mean_raw.png')) + im_median.save(os.path.join(imagepath, 'median_raw.png')) + im_min.save(os.path.join(imagepath, 'min_raw.png')) + im_max.save(os.path.join(imagepath, 'max_raw.png')) # Scale - im_center.resize((1920,1080), Image.BICUBIC).save(os.path.join(dirpath, 'center_hd.png')) - im_mean.resize((1920,1080), Image.BICUBIC).save(os.path.join(dirpath, 'mean_hd.png')) - im_median.resize((1920,1080), Image.BICUBIC).save(os.path.join(dirpath, 'median_hd.png')) - im_min.resize((1920,1080), Image.BICUBIC).save(os.path.join(dirpath, 'min_hd.png')) - im_max.resize((1920,1080), Image.BICUBIC).save(os.path.join(dirpath, 'max_hd.png')) + im_center.resize((1920,1080), Image.BICUBIC).save(os.path.join(imagepath, 'center_hd.png')) + im_mean.resize((1920,1080), Image.BICUBIC).save(os.path.join(imagepath, 'mean_hd.png')) + im_median.resize((1920,1080), Image.BICUBIC).save(os.path.join(imagepath, 'median_hd.png')) + im_min.resize((1920,1080), Image.BICUBIC).save(os.path.join(imagepath, 'min_hd.png')) + im_max.resize((1920,1080), Image.BICUBIC).save(os.path.join(imagepath, 'max_hd.png')) diff --git a/image/tasks.py b/image/tasks.py index 14214ac..31f2601 100644 --- a/image/tasks.py +++ b/image/tasks.py @@ -113,6 +113,11 @@ def make_daystrip(day): img.paste(picture.crop((0,400,2048,401)),(0,row)) imagepath = os.path.join(TIMELAPSE_DIR, APP_DIR, 'daystrip') + + # Make directory if it doesn't exist + if not os.path.exists(imagepath): + os.makedirs(imagepath) + filename = '{0}.png'.format(dayname) img_filepath = os.path.join(imagepath, filename) img.save(img_filepath) @@ -146,6 +151,11 @@ def make_daystrip_picture(day): img.paste(picture.crop((column,0,column+1,1536)),(column,0)) imagepath = os.path.join(TIMELAPSE_DIR, APP_DIR, 'daypic') + + # Make directory if it doesn't exist + if not os.path.exists(imagepath): + os.makedirs(imagepath) + filename = '{0}.png'.format(dayname) img_filepath = os.path.join(imagepath, filename) img.save(img_filepath)