add thumbnail for blender icons
This commit is contained in:
1 parent
1432c2990a
commit
e84c1148f3
68 files changed
+55
No files matched your search
@@ -1,7 +1,13 @@
|
|||||||
# My Ban
|
# My Ban
|
||||||
bbp_ng/PyBMap/*.dll
|
bbp_ng/PyBMap/*.dll
|
||||||
|
bbp_ng/PyBMap/*.so
|
||||||
|
bbp_ng/PyBMap/*.dylib
|
||||||
|
bbp_ng/PyBMap/*.bin
|
||||||
bbp_ng/PyBMap/*.pdb
|
bbp_ng/PyBMap/*.pdb
|
||||||
|
|
||||||
|
bbp_ng/icons/*
|
||||||
|
!bbp_ng/icons/.gitkeep
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
Whitespace-only changes.
File renamed without changes.
@@ -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.
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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()
|
||||||
Reference in new issue
Block a user