Add a touch more detail to size check

pull/355/head^2
Rod S 2021-06-25 21:01:47 -07:00
parent 9cba93e278
commit c3b9453a5b
1 changed files with 16 additions and 2 deletions

View File

@ -8,14 +8,22 @@ def _check_image(base_dir, image_dir):
assert image_dir.is_dir() assert image_dir.is_dir()
expected_size = (int(image_dir.name), int(image_dir.name)) expected_size = (int(image_dir.name), int(image_dir.name))
num_bad = 0
num_good = 0
for image_file in image_dir.iterdir(): for image_file in image_dir.iterdir():
with Image.open(image_file) as image: with Image.open(image_file) as image:
actual_size = image.size actual_size = image.size
if expected_size != actual_size: if expected_size != actual_size:
print(f"bad_dim {image_file.relative_to(base_dir)} actual {actual_size} expected {expected_size}") print(f"bad_dim {image_file.relative_to(base_dir)} actual {actual_size} expected {expected_size}")
num_bad += 1
else:
num_good += 1
return num_bad, num_good
def _check_svg(base_dir, svg_dir): def _check_svg(base_dir, svg_dir):
expected_viewbox = (0.0, 0.0, 128.0, 128.0) expected_viewbox = (0.0, 0.0, 128.0, 128.0)
num_bad = 0
num_good = 0
for svg_file in svg_dir.iterdir(): for svg_file in svg_dir.iterdir():
if not svg_file.name.startswith("emoji_u"): if not svg_file.name.startswith("emoji_u"):
continue continue
@ -25,6 +33,10 @@ def _check_svg(base_dir, svg_dir):
actual_viewbox = tuple(float(s) for s in actual_viewbox.split(" ")) actual_viewbox = tuple(float(s) for s in actual_viewbox.split(" "))
if expected_viewbox != actual_viewbox: if expected_viewbox != actual_viewbox:
print(f"bad_dim {svg_file.relative_to(base_dir)} actual {actual_viewbox} expected {expected_viewbox}") print(f"bad_dim {svg_file.relative_to(base_dir)} actual {actual_viewbox} expected {expected_viewbox}")
num_bad += 1
else:
num_good += 1
return num_bad, num_good
def main(): def main():
base_dir = Path(__file__).parent base_dir = Path(__file__).parent
@ -35,8 +47,10 @@ def main():
assert svg_dir.is_dir() assert svg_dir.is_dir()
for size_dir in image_dir.iterdir(): for size_dir in image_dir.iterdir():
_check_image(base_dir, size_dir) num_bad, num_good = _check_image(base_dir, size_dir)
_check_svg(base_dir, svg_dir) print(f"{num_bad}/{num_bad+num_good} issues with {size_dir}")
num_bad, num_good = _check_svg(base_dir, svg_dir)
print(f"{num_bad}/{num_bad+num_good} issues with {svg_dir}")
if __name__ == "__main__": if __name__ == "__main__":
main() main()