Genteki / pyvts

A python library for interacting with the VTube Studio API
https://genteki.github.io/pyvts/
MIT License
78 stars 11 forks source link

Fix plugin icon (fixes #39) #40

Closed boredofnames closed 1 year ago

boredofnames commented 1 year ago

Replaces instances of self.icon with self.plugin_icon

fixes #39

boredofnames commented 1 year ago

Whoops. Once I figure out how to run this testing stuff, I'll commit fixes.

Edit: I got a bit confused there with the testing kargs icon, my fault. Should be good now.

Unfortunately, this change is a breaking one. However, I think for consistency, this is more readable. Feel free to change to the plugin_info and request args back if you're unhappy with this.

Genteki commented 1 year ago

Good job!

Can you see the icon when getting authentication? I cannot see my icon, even if I've load the icon and encode with base64.

    def __read_icon(self, icon_path: str) -> str:
        icon_img = cv2.imread(icon_path)
        resized_img = cv2.resize(icon_img, (128, 128))
        _, im_arr = cv2.imencode('.png', resized_img)
        base64_icon =  base64.b64encode(im_arr.tobytes())
        return base64_icon

    def load_icon(self, icon_path: str) -> None:
        self.plugin_icon = self.__read_icon(icon_path)
boredofnames commented 1 year ago

Thanks 😀.

Try with:

def __read_icon(self, icon_path: str) -> str:
    icon_img = cv2.imread(icon_path)
    resized_img = cv2.resize(icon_img, (128, 128))
    _, im_arr = cv2.imencode('.png', resized_img)
    base64_icon =  base64.b64encode(im_arr).decode("UTF-8")
    return base64_icon

Also, I'd suggest using '.jpg' with imencode, you'll get a much smaller output.