Skip to content

Commit

Permalink
bg_color specified as rrggbbaa instead of rrggbb, allow setting bg_co…
Browse files Browse the repository at this point in the history
…lor with alpha!=0
  • Loading branch information
laggykiller committed Apr 20, 2024
1 parent 5558168 commit 0d2e1fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sticker_convert/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def __init__(

self.bg_color: Optional[Tuple[int, int, int, int]] = None
if self.opt_comp.bg_color:
r, g, b = bytes.fromhex(self.opt_comp.bg_color)
self.bg_color = (r, g, b, 0)
r, g, b, a = bytes.fromhex(self.opt_comp.bg_color)
self.bg_color = (r, g, b, a)

self.tmp_f: BytesIO = BytesIO()
self.result: Optional[bytes] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,14 @@ def cb_disable_fake_vid(self, *_: Any) -> None:
self.fake_vid_cbox.config(state=state)

def cb_bg_color(self, *_: Any) -> None:
color = colorchooser.askcolor(title="Choose color")[1]
color_init = self.gui.bg_color_var.get()[:6]
color = colorchooser.askcolor(
title="Choose color",
initialcolor=color_init,
parent=self,
)[1]
if color:
self.gui.bg_color_var.set(color.replace("#", ""))
self.gui.bg_color_var.set(color.replace("#", "") + "00")
self.lift()
self.attributes("-topmost", True) # type: ignore
self.attributes("-topmost", False) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion src/sticker_convert/resources/help.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"duration_min": "Set minimum output duration in miliseconds.",
"duration_max": "Set maximum output duration in miliseconds.",
"padding_percent": "Set percentage of space used as padding.",
"bg_color": "Set custom background color.\nExample: 00ff00 for green.\nIf this is not set, background color would be auto set to black if image is bright, or white if image is dark.\nNote: The color should not be visible if output format supports transparency.",
"bg_color": "Set custom background color in rrggbbaa format.\nExample: 00ff0000 for green with alpha 0.\nIf this is not set, background color would be auto set to black if image is bright, or white if image is dark.\nNote: The color should not be visible if output format supports transparency.",
"size": "Set maximum file size in bytes for video and image.",
"vid_size_max": "Set maximum file size limit for animated stickers.",
"img_size_max": "Set maximum file size limit for static stickers.",
Expand Down

0 comments on commit 0d2e1fa

Please sign in to comment.