Spaces:
Running
Running
| from PIL import Image | |
| import os | |
| # Source icon generated by AI | |
| source_path = r'C:\Users\fadhi\.gemini\antigravity\brain\0bc9ee3b-68d8-41f2-a1e9-068786fe9bd8\pest_scanner_icon_concept_1777746922722.png' | |
| # Project resource path | |
| res_path = r'c:\Users\fadhi\StudioProjects\pestDetection\app\src\main\res' | |
| # Mipmap sizes | |
| sizes = { | |
| 'mipmap-mdpi': 48, | |
| 'mipmap-hdpi': 72, | |
| 'mipmap-xhdpi': 96, | |
| 'mipmap-xxhdpi': 144, | |
| 'mipmap-xxxhdpi': 192 | |
| } | |
| def install_icons(): | |
| if not os.path.exists(source_path): | |
| print(f"Error: Source image not found at {source_path}") | |
| return | |
| img = Image.open(source_path) | |
| for folder, size in sizes.items(): | |
| folder_path = os.path.join(res_path, folder) | |
| if not os.path.exists(folder_path): | |
| os.makedirs(folder_path) | |
| # Resize | |
| resized_img = img.resize((size, size), Image.Resampling.LANCZOS) | |
| # Save as ic_launcher.webp | |
| launcher_path = os.path.join(folder_path, 'ic_launcher.webp') | |
| resized_img.save(launcher_path, 'WEBP') | |
| # Save as ic_launcher_round.webp | |
| round_path = os.path.join(folder_path, 'ic_launcher_round.webp') | |
| resized_img.save(round_path, 'WEBP') | |
| print(f"Installed icon to {folder} ({size}x{size})") | |
| print("\nSUCCESS! New app icons have been installed.") | |
| if __name__ == '__main__': | |
| install_icons() | |