mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Refactor tools/dupeframes.py
This commit is contained in:
parent
a32375c441
commit
d65443910b
@ -12,7 +12,7 @@ import glob
|
|||||||
|
|
||||||
import png
|
import png
|
||||||
|
|
||||||
def check_duplicate_frames(filename):
|
def duplicate_frames(filename):
|
||||||
with open(filename, 'rb') as file:
|
with open(filename, 'rb') as file:
|
||||||
width, height, rows = png.Reader(file).asRGBA8()[:3]
|
width, height, rows = png.Reader(file).asRGBA8()[:3]
|
||||||
rows = list(rows)
|
rows = list(rows)
|
||||||
@ -21,14 +21,12 @@ def check_duplicate_frames(filename):
|
|||||||
return
|
return
|
||||||
num_frames = height // width
|
num_frames = height // width
|
||||||
frames = [rows[i*width:(i+1)*width] for i in range(num_frames)]
|
frames = [rows[i*width:(i+1)*width] for i in range(num_frames)]
|
||||||
for i in range(num_frames):
|
yield from ((i, j) for i in range(num_frames) for j in range(i+1, num_frames) if frames[i] == frames[j])
|
||||||
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)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for filename in sorted(glob.glob('gfx/pokemon/*/front.png')):
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user