sticker-convert 2.7.9__tar.gz → 2.7.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sticker-convert-2.7.9/src/sticker_convert.egg-info → sticker-convert-2.7.11}/PKG-INFO +2 -2
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/requirements.txt +1 -1
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/converter.py +91 -73
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/job.py +1 -6
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/version.py +1 -1
- {sticker-convert-2.7.9 → sticker-convert-2.7.11/src/sticker_convert.egg-info}/PKG-INFO +2 -2
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/requires.txt +1 -1
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/LICENSE +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/MANIFEST.in +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/README.md +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/pyproject.toml +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/setup.cfg +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/__main__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/cli.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/definitions.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_base.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_kakao.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_line.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_signal.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_telegram.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/comp_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/config_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/control_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/cred_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/input_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/output_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/progress_frame.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/frames/right_clicker.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/gui_utils.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/advanced_compression_window.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/base_window.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/kakao_get_auth_window.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/line_get_auth_window.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/windows/signal_get_auth_window.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/.github/FUNDING.yml +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/.gitignore +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/README.md +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers/Info.plist +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Info.plist +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Sticker 1.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Sticker 2.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Sticker 3.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/App-Store-1024x1024pt.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Contents.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-App-Store-1024x768pt.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-67x50pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-Pro-74x55pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@3x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@3x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@3x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPad-Settings-29pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-Settings-29pt@3x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-settings-29pt@2x.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.pbxproj +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcuserdata/niklaspeterson.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/ios-message-stickers-template/stickers.xcodeproj/xcuserdata/niklaspeterson.xcuserdatad/xcschemes/xcschememanagement.plist +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/job_option.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/NotoColorEmoji.ttf +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/appicon.icns +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/appicon.ico +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/appicon.png +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/compression.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/emoji.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/help.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/input.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/output.json +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/__init__.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/compress_wastickers.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_base.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_signal.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_telegram.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/xcode_imessage.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_kakao_auth.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_line_auth.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_signal_auth.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/callback.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/cache_store.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/json_manager.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/json_resources_loader.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/metadata_handler.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/run_bin.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/sanitize_filename.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/apple_png_normalize.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/codec_info.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/decrypt_kakao.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/format_verify.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/url_detect.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/SOURCES.txt +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/dependency_links.txt +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/entry_points.txt +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/top_level.txt +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/tests/test_compression.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/tests/test_download.py +0 -0
- {sticker-convert-2.7.9 → sticker-convert-2.7.11}/tests/test_export.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sticker-convert
|
3
|
-
Version: 2.7.
|
3
|
+
Version: 2.7.11
|
4
4
|
Summary: Convert (animated) stickers to/from WhatsApp, Telegram, Signal, Line, Kakao, iMessage. Written in Python.
|
5
5
|
Author-email: laggykiller <chaudominic2@gmail.com>
|
6
6
|
Maintainer-email: laggykiller <chaudominic2@gmail.com>
|
@@ -378,7 +378,7 @@ Requires-Dist: Pillow==10.1.0
|
|
378
378
|
Requires-Dist: pyoxipng~=9.0.0
|
379
379
|
Requires-Dist: python-telegram-bot~=20.5
|
380
380
|
Requires-Dist: requests~=2.31.0
|
381
|
-
Requires-Dist: rlottie_python~=1.3.
|
381
|
+
Requires-Dist: rlottie_python~=1.3.4
|
382
382
|
Requires-Dist: signalstickers-client~=3.3.0
|
383
383
|
Requires-Dist: sqlcipher3-wheels~=0.5.2.post1
|
384
384
|
Requires-Dist: tqdm~=4.66.2
|
@@ -19,6 +19,7 @@ from sticker_convert.utils.media.codec_info import CodecInfo
|
|
19
19
|
from sticker_convert.utils.media.format_verify import FormatVerify
|
20
20
|
|
21
21
|
if TYPE_CHECKING:
|
22
|
+
from av.video.frame import VideoFrame # type: ignore
|
22
23
|
from av.video.plane import VideoPlane # type: ignore
|
23
24
|
|
24
25
|
MSG_START_COMP = "[I] Start compressing {} -> {}"
|
@@ -34,6 +35,14 @@ MSG_FAIL_COMP = (
|
|
34
35
|
"cannot get below limit {} with lowest quality under current settings (Best size: {})"
|
35
36
|
)
|
36
37
|
|
38
|
+
YUV_RGB_MATRIX = np.array(
|
39
|
+
[
|
40
|
+
[1.164, 0.000, 1.793],
|
41
|
+
[1.164, -0.213, -0.533],
|
42
|
+
[1.164, 2.112, 0.000],
|
43
|
+
]
|
44
|
+
)
|
45
|
+
|
37
46
|
|
38
47
|
def rounding(value: float) -> Decimal:
|
39
48
|
return Decimal(value).quantize(0, ROUND_HALF_UP)
|
@@ -76,6 +85,40 @@ def useful_array(
|
|
76
85
|
return arr.view(np.dtype(dtype))
|
77
86
|
|
78
87
|
|
88
|
+
def yuva_to_rgba(frame: "VideoFrame") -> "np.ndarray[Any, Any]":
|
89
|
+
# https://stackoverflow.com/questions/72308308/converting-yuv-to-rgb-in-python-coefficients-work-with-array-dont-work-with-n
|
90
|
+
|
91
|
+
width = frame.width
|
92
|
+
height = frame.height
|
93
|
+
|
94
|
+
y = useful_array(frame.planes[0]).reshape(height, width)
|
95
|
+
u = useful_array(frame.planes[1]).reshape(height // 2, width // 2)
|
96
|
+
v = useful_array(frame.planes[2]).reshape(height // 2, width // 2)
|
97
|
+
a = useful_array(frame.planes[3]).reshape(height, width)
|
98
|
+
|
99
|
+
u = u.repeat(2, axis=0).repeat(2, axis=1)
|
100
|
+
v = v.repeat(2, axis=0).repeat(2, axis=1)
|
101
|
+
|
102
|
+
y = y.reshape((y.shape[0], y.shape[1], 1))
|
103
|
+
u = u.reshape((u.shape[0], u.shape[1], 1))
|
104
|
+
v = v.reshape((v.shape[0], v.shape[1], 1))
|
105
|
+
a = a.reshape((a.shape[0], a.shape[1], 1))
|
106
|
+
|
107
|
+
yuv_array = np.concatenate((y, u, v), axis=2)
|
108
|
+
|
109
|
+
yuv_array = yuv_array.astype(np.float32)
|
110
|
+
yuv_array[:, :, 0] = (
|
111
|
+
yuv_array[:, :, 0].clip(16, 235).astype(yuv_array.dtype) - 16 # type: ignore
|
112
|
+
)
|
113
|
+
yuv_array[:, :, 1:] = (
|
114
|
+
yuv_array[:, :, 1:].clip(16, 240).astype(yuv_array.dtype) - 128 # type: ignore
|
115
|
+
)
|
116
|
+
|
117
|
+
rgb_array = np.matmul(yuv_array, YUV_RGB_MATRIX.T).clip(0, 255).astype("uint8")
|
118
|
+
|
119
|
+
return np.concatenate((rgb_array, a), axis=2)
|
120
|
+
|
121
|
+
|
79
122
|
class StickerConvert:
|
80
123
|
def __init__(
|
81
124
|
self,
|
@@ -131,6 +174,11 @@ class StickerConvert:
|
|
131
174
|
self.fps: Optional[Fraction] = None
|
132
175
|
self.color: Optional[int] = None
|
133
176
|
|
177
|
+
self.bg_color: Optional[Tuple[int, int, int, int]] = None
|
178
|
+
if self.opt_comp.bg_color:
|
179
|
+
r, g, b = bytes.fromhex(self.opt_comp.bg_color)
|
180
|
+
self.bg_color = (r, g, b, 0)
|
181
|
+
|
134
182
|
self.tmp_f: BytesIO = BytesIO()
|
135
183
|
self.result: Optional[bytes] = None
|
136
184
|
self.result_size: int = 0
|
@@ -407,10 +455,12 @@ class StickerConvert:
|
|
407
455
|
width = frame.width - 1
|
408
456
|
else:
|
409
457
|
width = frame.width
|
458
|
+
|
410
459
|
if frame.height % 2 != 0:
|
411
460
|
height = frame.height - 1
|
412
461
|
else:
|
413
462
|
height = frame.height
|
463
|
+
|
414
464
|
if frame.format.name == "yuv420p":
|
415
465
|
rgb_array = frame.to_ndarray(format="rgb24")
|
416
466
|
cast("np.ndarray[Any, Any]", rgb_array)
|
@@ -422,6 +472,7 @@ class StickerConvert:
|
|
422
472
|
)
|
423
473
|
else:
|
424
474
|
# yuva420p may cause crash
|
475
|
+
# Not safe to directly call frame.to_ndarray(format="rgba")
|
425
476
|
# https://github.com/laggykiller/sticker-convert/issues/114
|
426
477
|
frame = frame.reformat(
|
427
478
|
width=width,
|
@@ -429,50 +480,7 @@ class StickerConvert:
|
|
429
480
|
format="yuva420p",
|
430
481
|
dst_colorspace=1,
|
431
482
|
)
|
432
|
-
|
433
|
-
# https://stackoverflow.com/questions/72308308/converting-yuv-to-rgb-in-python-coefficients-work-with-array-dont-work-with-n
|
434
|
-
y = useful_array(frame.planes[0]).reshape(height, width)
|
435
|
-
u = useful_array(frame.planes[1]).reshape(
|
436
|
-
height // 2,
|
437
|
-
width // 2,
|
438
|
-
)
|
439
|
-
v = useful_array(frame.planes[2]).reshape(
|
440
|
-
height // 2,
|
441
|
-
width // 2,
|
442
|
-
)
|
443
|
-
a = useful_array(frame.planes[3]).reshape(height, width)
|
444
|
-
|
445
|
-
u = u.repeat(2, axis=0).repeat(2, axis=1)
|
446
|
-
v = v.repeat(2, axis=0).repeat(2, axis=1)
|
447
|
-
|
448
|
-
y = y.reshape((y.shape[0], y.shape[1], 1))
|
449
|
-
u = u.reshape((u.shape[0], u.shape[1], 1))
|
450
|
-
v = v.reshape((v.shape[0], v.shape[1], 1))
|
451
|
-
a = a.reshape((a.shape[0], a.shape[1], 1))
|
452
|
-
|
453
|
-
yuv_array = np.concatenate((y, u, v), axis=2)
|
454
|
-
|
455
|
-
yuv_array = yuv_array.astype(np.float32)
|
456
|
-
yuv_array[:, :, 0] = (
|
457
|
-
yuv_array[:, :, 0].clip(16, 235).astype(yuv_array.dtype) # type: ignore
|
458
|
-
- 16
|
459
|
-
)
|
460
|
-
yuv_array[:, :, 1:] = (
|
461
|
-
yuv_array[:, :, 1:].clip(16, 240).astype(yuv_array.dtype) # type: ignore
|
462
|
-
- 128
|
463
|
-
)
|
464
|
-
|
465
|
-
convert = np.array(
|
466
|
-
[
|
467
|
-
[1.164, 0.000, 1.793],
|
468
|
-
[1.164, -0.213, -0.533],
|
469
|
-
[1.164, 2.112, 0.000],
|
470
|
-
]
|
471
|
-
)
|
472
|
-
rgb_array = (
|
473
|
-
np.matmul(yuv_array, convert.T).clip(0, 255).astype("uint8")
|
474
|
-
)
|
475
|
-
rgba_array = np.concatenate((rgb_array, a), axis=2)
|
483
|
+
rgba_array = yuva_to_rgba(frame)
|
476
484
|
|
477
485
|
self.frames_raw.append(rgba_array)
|
478
486
|
|
@@ -505,6 +513,27 @@ class StickerConvert:
|
|
505
513
|
|
506
514
|
anim.lottie_animation_destroy()
|
507
515
|
|
516
|
+
def determine_bg_color(self) -> Tuple[int, int, int, int]:
|
517
|
+
# Calculate average color of all frames for selecting background color
|
518
|
+
frames_raw_np = np.array(self.frames_raw)
|
519
|
+
s = frames_raw_np.shape
|
520
|
+
colors = frames_raw_np.reshape((-1, s[3])) # type: ignore
|
521
|
+
# Do not count in alpha=0
|
522
|
+
# If alpha > 0, use alpha as weight
|
523
|
+
colors = colors[colors[:, 3] != 0]
|
524
|
+
if colors.shape[0] == 0:
|
525
|
+
return (0, 0, 0, 0)
|
526
|
+
else:
|
527
|
+
alphas = colors[:, 3] / 255
|
528
|
+
r_mean = np.mean(colors[:, 0] * alphas)
|
529
|
+
g_mean = np.mean(colors[:, 1] * alphas)
|
530
|
+
b_mean = np.mean(colors[:, 2] * alphas)
|
531
|
+
mean = (r_mean + g_mean + b_mean) / 3
|
532
|
+
if mean < 128:
|
533
|
+
return (255, 255, 255, 0)
|
534
|
+
else:
|
535
|
+
return (0, 0, 0, 0)
|
536
|
+
|
508
537
|
def frames_resize(
|
509
538
|
self, frames_in: "List[np.ndarray[Any, Any]]"
|
510
539
|
) -> "List[np.ndarray[Any, Any]]":
|
@@ -526,25 +555,8 @@ class StickerConvert:
|
|
526
555
|
else:
|
527
556
|
resample = Image.BICUBIC
|
528
557
|
|
529
|
-
if
|
530
|
-
|
531
|
-
frames_raw_np = np.array(self.frames_raw)
|
532
|
-
s = frames_raw_np.shape
|
533
|
-
colors = frames_raw_np.reshape((-1, s[3])) # type: ignore
|
534
|
-
# Do not count in alpha=0
|
535
|
-
# If alpha > 0, use alpha as weight
|
536
|
-
colors = colors[colors[:, 3] != 0]
|
537
|
-
if colors.shape[0] == 0:
|
538
|
-
bg = (0, 0, 0, 0)
|
539
|
-
else:
|
540
|
-
colors = colors * (colors[3] / 255)
|
541
|
-
if np.mean(colors[:, :3]) < 128:
|
542
|
-
bg = (255, 255, 255, 0)
|
543
|
-
else:
|
544
|
-
bg = (0, 0, 0, 0)
|
545
|
-
else:
|
546
|
-
r, g, b = bytes.fromhex(self.opt_comp.bg_color)
|
547
|
-
bg = (r, g, b, 0)
|
558
|
+
if self.bg_color is None:
|
559
|
+
self.bg_color = self.determine_bg_color()
|
548
560
|
|
549
561
|
for frame in frames_in:
|
550
562
|
with Image.fromarray(frame, "RGBA") as im: # type: ignore
|
@@ -563,7 +575,9 @@ class StickerConvert:
|
|
563
575
|
width_new = width * self.res_h // height
|
564
576
|
|
565
577
|
with im.resize((width_new, height_new), resample=resample) as im_resized:
|
566
|
-
with Image.new(
|
578
|
+
with Image.new(
|
579
|
+
"RGBA", (self.res_w, self.res_h), self.bg_color
|
580
|
+
) as im_new:
|
567
581
|
im_new.alpha_composite(
|
568
582
|
im_resized,
|
569
583
|
((self.res_w - width_new) // 2, (self.res_h - height_new) // 2),
|
@@ -700,20 +714,24 @@ class StickerConvert:
|
|
700
714
|
else:
|
701
715
|
extra_kwargs["optimize"] = True
|
702
716
|
|
703
|
-
#
|
704
|
-
#
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
) #
|
709
|
-
if
|
717
|
+
# GIF can only have one alpha color
|
718
|
+
# Change lowest alpha to alpha=0
|
719
|
+
# Only keep alpha=0 and alpha=255, nothing in between
|
720
|
+
frames_processed = np.array(self.frames_processed)
|
721
|
+
alpha = frames_processed[:, :, :, 3]
|
722
|
+
alpha_min = np.min(alpha) # type: ignore
|
723
|
+
if alpha_min < 255:
|
724
|
+
alpha[alpha > alpha_min] = 255
|
725
|
+
alpha[alpha == alpha_min] = 0
|
726
|
+
|
727
|
+
if 0 in alpha:
|
710
728
|
extra_kwargs["transparency"] = 0
|
711
729
|
extra_kwargs["disposal"] = 2
|
712
|
-
im_out = [self.quantize(Image.fromarray(i)) for i in
|
730
|
+
im_out = [self.quantize(Image.fromarray(i)) for i in frames_processed]
|
713
731
|
else:
|
714
732
|
im_out = [
|
715
733
|
self.quantize(Image.fromarray(i).convert("RGB")).convert("RGB")
|
716
|
-
for i in
|
734
|
+
for i in frames_processed
|
717
735
|
]
|
718
736
|
|
719
737
|
if self.fps:
|
@@ -2,7 +2,6 @@
|
|
2
2
|
from __future__ import annotations
|
3
3
|
|
4
4
|
import os
|
5
|
-
import platform
|
6
5
|
import shutil
|
7
6
|
import traceback
|
8
7
|
from datetime import datetime
|
@@ -182,11 +181,7 @@ class Executor:
|
|
182
181
|
self.is_cancel_job.value = 1 # type: ignore
|
183
182
|
|
184
183
|
for process in self.processes:
|
185
|
-
|
186
|
-
process.terminate()
|
187
|
-
else:
|
188
|
-
process.close()
|
189
|
-
process.join()
|
184
|
+
process.terminate()
|
190
185
|
|
191
186
|
self.cleanup(killed=True)
|
192
187
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sticker-convert
|
3
|
-
Version: 2.7.
|
3
|
+
Version: 2.7.11
|
4
4
|
Summary: Convert (animated) stickers to/from WhatsApp, Telegram, Signal, Line, Kakao, iMessage. Written in Python.
|
5
5
|
Author-email: laggykiller <chaudominic2@gmail.com>
|
6
6
|
Maintainer-email: laggykiller <chaudominic2@gmail.com>
|
@@ -378,7 +378,7 @@ Requires-Dist: Pillow==10.1.0
|
|
378
378
|
Requires-Dist: pyoxipng~=9.0.0
|
379
379
|
Requires-Dist: python-telegram-bot~=20.5
|
380
380
|
Requires-Dist: requests~=2.31.0
|
381
|
-
Requires-Dist: rlottie_python~=1.3.
|
381
|
+
Requires-Dist: rlottie_python~=1.3.4
|
382
382
|
Requires-Dist: signalstickers-client~=3.3.0
|
383
383
|
Requires-Dist: sqlcipher3-wheels~=0.5.2.post1
|
384
384
|
Requires-Dist: tqdm~=4.66.2
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/__init__.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_base.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_kakao.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_line.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/downloaders/download_signal.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/gui_components/gui_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/NotoColorEmoji.ttf
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/resources/compression.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_base.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_signal.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/upload_telegram.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/uploaders/xcode_imessage.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_kakao_auth.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_line_auth.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/auth/get_signal_auth.py
RENAMED
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/cache_store.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/json_manager.py
RENAMED
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/files/metadata_handler.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/codec_info.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/decrypt_kakao.py
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert/utils/media/format_verify.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/dependency_links.txt
RENAMED
File without changes
|
{sticker-convert-2.7.9 → sticker-convert-2.7.11}/src/sticker_convert.egg-info/entry_points.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|