Skip to content

Commit

Permalink
Refactor tools/dupeframes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Nov 23, 2023
1 parent 0fc938c commit 04e23a8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tools/dupeframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import png

def check_duplicate_frames(filename):
def duplicate_frames(filename):
with open(filename, 'rb') as file:
width, height, rows = png.Reader(file).asRGBA8()[:3]
rows = list(rows)
Expand All @@ -21,14 +21,12 @@ def check_duplicate_frames(filename):
return
num_frames = height // width
frames = [rows[i*width:(i+1)*width] for i in range(num_frames)]
for i in range(num_frames):
for j in range(i + 1, num_frames):
if frames[i] == frames[j]:
print(f'{filename}: frame {j} is a duplicate of frame {i}', file=sys.stderr)
yield from ((i, j) for i in range(num_frames) for j in range(i+1, num_frames) if frames[i] == frames[j])

def main():
for filename in sorted(glob.glob('gfx/pokemon/*/front.png')):
check_duplicate_frames(filename)
for (i, j) in duplicate_frames(filename):
print(f'{filename}: frame {j} is a duplicate of frame {i}', file=sys.stderr)

if __name__ == '__main__':
main()

0 comments on commit 04e23a8

Please sign in to comment.