add thumbnail for blender icons
6
.gitignore
vendored
@ -1,7 +1,13 @@
|
||||
# My Ban
|
||||
bbp_ng/PyBMap/*.dll
|
||||
bbp_ng/PyBMap/*.so
|
||||
bbp_ng/PyBMap/*.dylib
|
||||
bbp_ng/PyBMap/*.bin
|
||||
bbp_ng/PyBMap/*.pdb
|
||||
|
||||
bbp_ng/icons/*
|
||||
!bbp_ng/icons/.gitkeep
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
0
bbp_ng/icons/.gitkeep
Normal file
Before Width: | Height: | Size: 785 B After Width: | Height: | Size: 785 B |
7
bbp_ng/raw_icons/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Raw Icons
|
||||
|
||||
This folder contain all images used by this Blender plugin.
|
||||
|
||||
This folder should not be distributed in production because all of these files are in original size. It is pretty need too much time to load them in blender.
|
||||
So we keep these high quality images here and provide a tools in `tools` folder. Builder should run script to generate thumbnails in `icons` folder.
|
||||
Then this Blender plugin can work normally.
|
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 663 B |
Before Width: | Height: | Size: 745 B After Width: | Height: | Size: 745 B |
Before Width: | Height: | Size: 945 B After Width: | Height: | Size: 945 B |
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 818 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 984 B After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 775 B After Width: | Height: | Size: 775 B |
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 652 B After Width: | Height: | Size: 652 B |
Before Width: | Height: | Size: 695 B After Width: | Height: | Size: 695 B |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
42
bbp_ng/tools/build_icons.py
Normal file
@ -0,0 +1,42 @@
|
||||
import os
|
||||
import PIL, PIL.Image
|
||||
|
||||
# the config for thumbnail
|
||||
g_ThumbnailSize: int = 16
|
||||
|
||||
def resize_image(src_file: str, dst_file: str) -> None:
|
||||
# open image
|
||||
src_image: PIL.Image.Image = PIL.Image.open(src_file)
|
||||
# create thumbnail
|
||||
src_image.thumbnail((g_ThumbnailSize, g_ThumbnailSize))
|
||||
# save to new file
|
||||
src_image.save(dst_file)
|
||||
|
||||
def relative_to_folder(abs_path: str, src_parent: str, dst_parent: str) -> str:
|
||||
return os.path.join(dst_parent, os.path.relpath(abs_path, src_parent))
|
||||
|
||||
def create_thumbnails() -> None:
|
||||
# get folder path
|
||||
root_folder: str = os.path.dirname(os.path.dirname(__file__))
|
||||
raw_icons_folder: str = os.path.join(root_folder, 'raw_icons')
|
||||
icons_folder: str = os.path.join(root_folder, 'icons')
|
||||
|
||||
# iterate raw icons folder
|
||||
for root, dirs, files in os.walk(raw_icons_folder, topdown = True):
|
||||
# iterate folder and create it in dest folder
|
||||
for name in dirs:
|
||||
src_folder: str = os.path.join(root, name)
|
||||
dst_folder: str = relative_to_folder(src_folder, raw_icons_folder, icons_folder)
|
||||
print(f'Creating Folder: {src_folder} -> {dst_folder}')
|
||||
os.makedirs(dst_folder, exist_ok = True)
|
||||
for name in files:
|
||||
if not name.endswith('.png'): continue # skip non-image
|
||||
src_file: str = os.path.join(root, name)
|
||||
dst_file: str = relative_to_folder(src_file, raw_icons_folder, icons_folder)
|
||||
print(f'Processing Thumbnail: {src_file} -> {dst_file}')
|
||||
resize_image(src_file, dst_file)
|
||||
|
||||
print('Done.')
|
||||
|
||||
if __name__ == '__main__':
|
||||
create_thumbnails()
|