diff --git a/src/api.py b/src/api.py index 7531a58..c4b1f2c 100644 --- a/src/api.py +++ b/src/api.py @@ -1,7 +1,7 @@ import os import sys import subprocess -from utils import api_file_path, data_folder_path, icons_folder_path, display_notification, language, padding +from utils import api_file_path, data_folder_path, icons_folder_path, assets_folder_path, display_notification, language, padding def get_homebrew_prefix(): try: prefix = subprocess.check_output(['brew', '--prefix']) @@ -41,7 +41,7 @@ def get_homebrew_prefix(): check_e_type = ['flag:', 'keycap:'] def convert_emoji_to_png(emoji, name): - image_size = (64+padding, 64+padding) # set image size + image_size = (64 + padding, 64 + padding) # set image size image = Image.new("RGBA", image_size, (0, 0, 0, 0)) # Set transparent background font_size = 64 # Adjusted font size font_path = "/System/Library/Fonts/Apple Color Emoji.ttc" @@ -100,6 +100,17 @@ def convert_emoji_to_png(emoji, name): with open(api_file_path, 'w', encoding='utf-8') as file: json.dump({'info': info, 'items': items}, file, ensure_ascii=False, indent=4) + assets = [f for f in os.listdir(assets_folder_path)] + + for i in assets: + image_path = os.path.join(assets_folder_path, i) + image = Image.open(image_path) + width, height = image.size + new_image = Image.new("RGBA", (width + padding, height + padding), (0, 0, 0, 0)) + new_image.paste(image, (int(padding / 2), int(padding / 2))) + output_path = os.path.join(icons_folder_path, i) + new_image.save(output_path) + display_notification('✅ Success !', 'Data updated. You can search emojis') except: display_notification('🚨 Error !', 'Something went wrong, check your internet connexion or create a GitHub issue') \ No newline at end of file diff --git a/src/icons/assets/emojipedia.png b/src/icons/assets/emojipedia.png new file mode 100644 index 0000000..4b2ae7c Binary files /dev/null and b/src/icons/assets/emojipedia.png differ diff --git a/src/icons/emojipedia.webp b/src/icons/emojipedia.webp deleted file mode 100644 index 03bfcc0..0000000 Binary files a/src/icons/emojipedia.webp and /dev/null differ diff --git a/src/info.plist b/src/info.plist index 5a0f72f..744aeba 100644 --- a/src/info.plist +++ b/src/info.plist @@ -1209,8 +1209,10 @@ note: not all emojis are available in all languages. sound + variablesdontexport + version - 1.2.4 + 1.2.5 webaddress https://github.com/BenjaminOddou/alfred-emoji-wine diff --git a/src/utils.py b/src/utils.py index 9e91142..2828fe9 100644 --- a/src/utils.py +++ b/src/utils.py @@ -9,6 +9,7 @@ padding = 10 cache_folder_path = os.environ['alfred_workflow_cache'] # ~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine data_folder_path = os.environ['alfred_workflow_data'] # ~/Library/Application Support/Alfred/Workflow Data/com.benjamino.emoji_wine +assets_folder_path = f'{os.getcwd()}/icons/assets' api_file_path = f'{cache_folder_path}/api.json' tags_file_path = f'{data_folder_path}/tags-{language}.json' icons_folder_path = f'{cache_folder_path}/icons' diff --git a/src/wine.py b/src/wine.py index f3b7003..7048518 100644 --- a/src/wine.py +++ b/src/wine.py @@ -64,7 +64,7 @@ 'subtitle': 'Find the emoji in emojipedia', 'arg': f'_web;{country}/{url}', 'icon': { - 'path': 'icons/emojipedia.webp', + 'path': f'{icons_folder_path}/emojipedia.png', }, } })