-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] Add delete_duplicate_images.py script to replace --skip-idle
- Loading branch information
1 parent
3868924
commit 5465c08
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import argparse | ||
import pathlib | ||
|
||
parser = argparse.ArgumentParser( | ||
description="This script deletes successions of duplicated images in the folder, leaving just one per event entailing a visual change." | ||
) | ||
parser.add_argument( | ||
"-o", "--output-folder", default="screenshots_each_step", help="output folder" | ||
) | ||
|
||
|
||
def main(): | ||
args = parser.parse_args() | ||
folder = pathlib.Path(args.output_folder) / "images" | ||
# Compare png contents and remove successive duplicates | ||
previousImage = b"" | ||
for png in sorted(folder.glob("img-*.png")): | ||
image = png.read_bytes() | ||
if image == previousImage: | ||
png.unlink() | ||
else: | ||
previousImage = image | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |