Skip to content

Commit

Permalink
fix: adapt emojipedia icon size
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminOddou committed Sep 16, 2023
1 parent caa8620 commit eda3837
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/api.py
Original file line number Diff line number Diff line change
@@ -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'])
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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')
Binary file added src/icons/assets/emojipedia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/icons/emojipedia.webp
Binary file not shown.
4 changes: 3 additions & 1 deletion src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,10 @@ note: not all emojis are available in all languages.</string>
<string>sound</string>
</dict>
</array>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.2.4</string>
<string>1.2.5</string>
<key>webaddress</key>
<string>https://github.com/BenjaminOddou/alfred-emoji-wine</string>
</dict>
Expand Down
1 change: 1 addition & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/wine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}
})
Expand Down

0 comments on commit eda3837

Please sign in to comment.