Screenshot: Retain access times in archive

This commit is contained in:
Akemi Izuko 2022-11-25 13:27:32 -07:00
parent f39d60a587
commit 60f3ddca21
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4

View file

@ -175,9 +175,15 @@ def archive_subcommand(args):
sys.stdout.write(f'Progress: 0/{count}')
for i, pic in enumerate(pics):
with Image.open(DIR/pic) as img:
img.save(TMP_DIR/pic.with_suffix(ext),
quality=args.quality, method=6, optimize=True)
og = DIR/pic
out = TMP_DIR/pic.with_suffix(ext)
with Image.open(og) as img:
img.save(out, quality=args.quality, method=6, optimize=True)
stat = os.stat(og)
os.utime(out, times=(stat.st_atime, stat.st_mtime))
sys.stdout.write(f'\rProgress: {i+1}/{count}' + ' ' * 40)
sys.stdout.write('\nDone!\n')