python3: upgrade to release 3.8.13
[LibreOffice.git] / bin / check-icon-sizes.py
blob535caa3efa2661dedd02b82c7418a332c21b0cba
1 #!/usr/bin/env python3
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import os
12 from PIL import Image
14 """
15 This script walks through all icon files and checks whether the sc_* and lc_* files have the correct size.
16 """
18 icons_folder = os.path.abspath(os.path.join(__file__, '..', '..', 'icon-themes'))
20 def check_size(filename, size):
21 image = Image.open(filename)
22 width, height = image.size
23 if width != size or height != size:
24 print("%s has size %dx%d but should have %dx%d" % (filename, width, height, size, size))
26 for root, dirs, files in os.walk(icons_folder):
27 for filename in files:
28 if not filename.endswith('png'):
29 continue
30 if filename.startswith('lc_'):
31 check_size(os.path.join(root, filename), 24)
32 elif filename.startswith('sc_'):
33 check_size(os.path.join(root, filename), 16)