Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new tag #8

Closed
garymh opened this issue Feb 27, 2024 · 20 comments
Closed

Creating a new tag #8

garymh opened this issue Feb 27, 2024 · 20 comments

Comments

@garymh
Copy link

garymh commented Feb 27, 2024

Hi - this might be a dumb question, but I'm a little confused on how you enter the tag section. Typing the harvest keyword brings up:

Screenshot 2024-02-26 at 20 32 54

but after that, hitting return on the Tags section just closes the Alfred window. Typing any arguments (harvest tag) just goes to my default search...

I'm using Python 3.12.2 and pillow 10.2.0_1

@BenjaminOddou
Copy link
Owner

Hi @garymh

I'll try to figure out what's causing the issue. Could you give me the Alfred logs ?

@garymh
Copy link
Author

garymh commented Feb 27, 2024

Sure!

[08:58:54.871] Logging Started...
[08:59:00.788] Emoji Wine[Script Filter] Queuing argument '(null)'
[08:59:01.084] Emoji Wine[Script Filter] Script with argv '(null)' finished
[08:59:01.089] Emoji Wine[Script Filter] {"items": [{"title": "Refresh the API", "subtitle": "Press \u23ce to grab emoji data with language : \ud83c\uddec\ud83c\udde7 English", "arg": "_api", "icon": {"path": "icons/sync.webp"}}, {"title": "Tags", "subtitle": "Create, modify or remove tags for \ud83c\uddec\ud83c\udde7 English", "arg": "_rerun;;1;;", "icon": {"path": "icons/tag.webp"}}, {"title": "API information", "subtitle": "Last update : 26-07-2023 19:29:31 \u01c0 3664 Emojis \u01c0 \ud83c\uddec\ud83c\udde7 English", "valid": false, "icon": {"path": "icons/info.webp"}}]}
[08:59:03.322] Emoji Wine[Script Filter] Processing complete
[08:59:03.326] Emoji Wine[Script Filter] Passing output '_rerun;;1;;' to Split Arg
[08:59:03.327] Emoji Wine[Split Arg] Processing complete
[08:59:03.327] Emoji Wine[Split Arg] Passing output '_rerun;;1;;' to Conditional
[08:59:03.328] Emoji Wine[Conditional] Processing complete
[08:59:03.328] Emoji Wine[Conditional] Passing output '_rerun;;1;;' to Call External Trigger
[08:59:03.329] Emoji Wine[External] Processing complete
[08:59:03.329] Emoji Wine[External] Passing output '_rerun;;1;;' to Arg and Vars
[08:59:03.330] Emoji Wine[Arg and Vars] Processing complete
[08:59:03.330] Emoji Wine[Arg and Vars] Passing output '' to Script Filter
[08:59:03.372] Emoji Wine[Script Filter] Queuing argument '(null)'

@BenjaminOddou
Copy link
Owner

really strange, could you confirm me that you have version 1.3.0 of the workflow ?

When I trigger harvest :

[21:55:42.438] Logging Started...
[21:55:46.690] Emoji Wine[Script Filter] Queuing argument '(null)'
[21:55:46.878] Emoji Wine[Script Filter] Script with argv '(null)' finished
[21:55:46.879] Emoji Wine[Script Filter] {"items": [{"title": "Refresh the API", "subtitle": "Press \u23ce to grab emoji data with language : \ud83c\uddec\ud83c\udde7 English", "arg": "_api", "icon": {"path": "icons/sync.webp"}}, {"title": "Tags", "subtitle": "Create, modify or remove tags for \ud83c\uddec\ud83c\udde7 English", "arg": "_rerun;;1;;", "icon": {"path": "icons/tag.webp"}}, {"title": "API information", "subtitle": "Last update : 10-02-2024 18:16:56 \u01c0 3782 Emojis \u01c0 \ud83c\uddec\ud83c\udde7 English", "valid": false, "icon": {"path": "icons/info.webp"}}]}
[21:55:48.515] Emoji Wine[Script Filter] Processing complete
[21:55:48.517] Emoji Wine[Script Filter] Passing output '_rerun;;1;;' to Split Arg
[21:55:48.518] Emoji Wine[Split Arg] Processing complete
[21:55:48.520] Emoji Wine[Split Arg] Passing output '_rerun;;1;;' to Conditional
[21:55:48.522] Emoji Wine[Conditional] Processing complete
[21:55:48.524] Emoji Wine[Conditional] Passing output '_rerun;;1;;' to Call External Trigger
[21:55:48.525] Emoji Wine[External] Processing complete
[21:55:48.527] Emoji Wine[External] Passing output '_rerun;;1;;' to Arg and Vars
[21:55:48.543] Emoji Wine[Arg and Vars] Processing complete
[21:55:48.545] Emoji Wine[Arg and Vars] Passing output '' to Script Filter
[21:55:48.547] Emoji Wine[Script Filter] Queuing argument '(null)'
[21:55:48.759] Emoji Wine[Script Filter] Script with argv '(null)' finished
[21:55:48.766] Emoji Wine[Script Filter] {"items": [{"title": "Return", "subtitle": "Back to previous state", "arg": "_rerun;;0;;", "icon": {"path": "icons/return.webp"}}, {"title": "Add a new tag", "subtitle": "Create a new tag and assign it to emojis", "arg": "_tags;new;;;_rerun\u01c0\u01c01\u01c0\u01c0", "icon": {"path": "icons/new.webp"}}, {"title": "Delete a tag", "subtitle": "Erase a tag from the list below", "arg": "_rerun;delete;2;;", "icon": {"path": "icons/delete.webp"}}]}

I am seeing this :

Capture d’écran 2024-02-27 à 22 11 04

From there you can create tags and associate it to emojis.

@garymh
Copy link
Author

garymh commented Feb 27, 2024

Oh weird... hmm. Yep, I have version 1.3.0. Something might be configured differently in Alfred... or in Python?

@BenjaminOddou
Copy link
Owner

could you check that you have tags-en.json file here : ~/Library/Application Support/Alfred/Workflow Data/com.benjamino.emoji_wineand also please check for any error in the workflow logs located here ~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine

@garymh
Copy link
Author

garymh commented Feb 28, 2024

Yep- I have tags-en.json:

~/L/Application Support/Alfred/Workflow Data/com.benjamino.emoji_wine
❯ cat tags-en.json
   1   []

My emoji_wine.log file is:

  1   2024-02-26 12:36:07,687 - ERROR - unimplemented feature
   2   2024-02-26 20:20:22,459 - ERROR - unimplemented feature
   3   2024-02-26 20:21:29,685 - ERROR - unimplemented feature
   4   2024-02-26 20:24:12,546 - ERROR - unimplemented feature
   5   2024-02-26 20:42:28,073 - ERROR - unimplemented feature

@BenjaminOddou
Copy link
Owner

Could you try to refresh your API ?

@garymh
Copy link
Author

garymh commented Feb 28, 2024

Screenshot 2024-02-28 at 13 31 02

Weirdly, this started happening - I used to be able to get the initial list of emoji

@BenjaminOddou
Copy link
Owner

Yes I think something is not configured correctly but I can't really know what's happening. How did you install python ? Could you also give me the new logs ? Could you maybe try to reinstall the workflow (just to make sure). I'll try my best to debug.

@garymh
Copy link
Author

garymh commented Feb 29, 2024

I installed Python via homebrew. I uninstalled it via command line and then reinstalled it through Alfred, but nothing. I reinstalled the workflow several times after clearing out ~/Library/Application Support/Alfred/Workflow Data/com.benjamino.emoji_wine and ~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine

The only log I get is the ERROR - unimplemented feature line...

@garymh
Copy link
Author

garymh commented Feb 29, 2024

It must be something with convert_emoji_to_png- I commented out the call on line 94 of api.py and everything worked perfectly. 🤔

@BenjaminOddou
Copy link
Owner

Ok then. Could you confirm me that you don't have any emojis icons when you trigger wine ? There might be something with pillow but as you seems to have the latest version 🤔. Could you also check that you have the emoji font here /System/Library/Fonts/Apple Color Emoji.ttc. I put that raw meaning I expect it's always available under this path, but maybe on newer Macs (I have an intel chip) the path is different ?

@garymh
Copy link
Author

garymh commented Feb 29, 2024

Some of the emoji icons appear, I'm not sure if they're sorted but it stops at "person facing right".

Yep- emoji font is in the same place. I am on an M1 though

@BenjaminOddou
Copy link
Owner

BenjaminOddou commented Mar 2, 2024

mhh kind of weird. Is it possible that the emojis without icons are emojis from unicode 15.1 ? There aren't available yet but the unicode is already in the api since end of 2023 (see this article). But it shouldn't be a problem, for me it looks like this:

mushroom

Could you delete these elements from the cache folder ~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine before refreshing the API ?

cache

EDIT : Could you try this python script ?

from PIL import Image, ImageDraw, ImageFont

def convert_emoji_to_png(emoji):
    image_size = (74 , 74) # 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"
    font = ImageFont.truetype(font_path, font_size, encoding='unic')
    draw_position = (int((image_size[0] - font_size) / 2), int((image_size[1] - font_size) / 2))
    draw = ImageDraw.Draw(image)
    draw.text(draw_position, emoji, font=font, embedded_color=True)
    image.show()

try:
    convert_emoji_to_png("🚶‍➡️")
except Exception as e:
    print(e)

it should render this

render

@garymh
Copy link
Author

garymh commented Mar 2, 2024

Same result after dumping the cache 😞

Oh, but the python script did:

❯ python3 test.py
unimplemented feature

@garymh
Copy link
Author

garymh commented Mar 2, 2024

it possible that the emojis without icons are emojis from unicode 15.1

I think you might be on to something! 🍄 works but 🚶‍➡️does not. I wonder if it's because there's a modifier on that one?

I'm not sure how emoji works, but is there an emoji + skin tone modifier in Unicode?

@BenjaminOddou
Copy link
Owner

I can fix that by just ignoring emojis that fails to be converted into images, or assign them a default image. Also, is there any improvement in the tags section (that was the original subject 🙃)?

Yes some of the codes can be "merged" as one emoji (👋 + 🏻 = 👋🏻, see here). When the Unicode consortium approved an emoji, each platform (Google, Facebook, Apple) can integrate these codes with a design. Note that the design can change over the years but not the codes.

What I still find weird is : why the behavior is different ? Maybe we can create a GitHub issue in the pillow repo. I can do that if you can provide :

  • The python version (3.12.2) ?
  • The pillow version (10.2.0) ?
  • The MacOS version
  • Your chip

@garymh
Copy link
Author

garymh commented Mar 3, 2024

I can fix that by just ignoring emojis that fails to be converted into images, or assign them a default image. Also, is there any improvement in the tags section (that was the original subject 🙃)?

Yep! Disabling the line here let me run everything correctly. Definitely seemed to be a unicode hangup.

What I still find weird is : why the behavior is different ? Maybe we can create a GitHub issue in the pillow repo. I can do that if you can provide :

Yeah, that's very strange. I'm wondering if macOS changed something recently too. Here's my info:

Python 3.12.2
pillow stable 10.2.0
macOS 14.4
Apple M1 Max

BenjaminOddou added a commit that referenced this issue Mar 3, 2024
- If the conversion of an emoji fails to be converted by pillow, link the emoji to the default unicode logo #8
- force the api refresh when upgrading version
- remove unnecessary conditions for tags
@BenjaminOddou
Copy link
Owner

@garymh it should be fix in the v1.4.0. Emojis that fails to be converted should have this icon :

fail

@garymh
Copy link
Author

garymh commented Mar 3, 2024

Awesome!! Thanks for the help, Benjamin!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants