sticker-convert 2.8.9__py3-none-any.whl → 2.8.11__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- sticker_convert/cli.py +1 -4
- sticker_convert/converter.py +38 -84
- sticker_convert/gui.py +0 -2
- sticker_convert/gui_components/frames/comp_frame.py +0 -1
- sticker_convert/gui_components/windows/advanced_compression_window.py +0 -16
- sticker_convert/job_option.py +0 -1
- sticker_convert/resources/compression.json +0 -12
- sticker_convert/resources/help.json +0 -1
- sticker_convert/utils/media/codec_info.py +23 -19
- sticker_convert/version.py +1 -1
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/METADATA +25 -21
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/RECORD +16 -16
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/LICENSE +0 -0
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/WHEEL +0 -0
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/entry_points.txt +0 -0
- {sticker_convert-2.8.9.dist-info → sticker_convert-2.8.11.dist-info}/top_level.txt +0 -0
sticker_convert/cli.py
CHANGED
@@ -136,7 +136,7 @@ class CLI:
|
|
136
136
|
"scale_filter",
|
137
137
|
"quantize_method",
|
138
138
|
)
|
139
|
-
flags_comp_bool = ("fake_vid",
|
139
|
+
flags_comp_bool = ("fake_vid",)
|
140
140
|
keyword_args: Dict[str, Any]
|
141
141
|
for k, v in self.help["comp"].items():
|
142
142
|
if k in flags_comp_int:
|
@@ -390,9 +390,6 @@ class CLI:
|
|
390
390
|
fake_vid=self.compression_presets[preset]["fake_vid"]
|
391
391
|
if args.fake_vid is None
|
392
392
|
else args.fake_vid,
|
393
|
-
force_pywebp=self.compression_presets[preset]["force_pywebp"]
|
394
|
-
if args.force_pywebp is None
|
395
|
-
else args.force_pywebp,
|
396
393
|
cache_dir=args.cache_dir,
|
397
394
|
scale_filter=self.compression_presets[preset]["scale_filter"]
|
398
395
|
if args.scale_filter is None
|
sticker_convert/converter.py
CHANGED
@@ -33,19 +33,6 @@ MSG_FAIL_COMP = (
|
|
33
33
|
"[F] Failed Compression {} -> {}, "
|
34
34
|
"cannot get below limit {} with lowest quality under current settings (Best size: {})"
|
35
35
|
)
|
36
|
-
MSG_PYWEBP_FLAG_SET = "`--force-pywebp` was set\n"
|
37
|
-
MSG_PYWEBP_NO_LIBWEBP = "system WebP>=0.5.0 was not found.\n"
|
38
|
-
MSG_PYWEBP_DUPFRAME = (
|
39
|
-
"[W] {} contains duplicated frame.\n"
|
40
|
-
" Using pywebp instead of Pillow as {}"
|
41
|
-
" This is faster, but known to collapse same frames into single frame,\n"
|
42
|
-
" causing problem with animation timing."
|
43
|
-
)
|
44
|
-
MSG_WEBP_PIL_DUPFRAME = (
|
45
|
-
"[W] {} contains duplicated frame.\n"
|
46
|
-
" Using Pillow to create animated webp to avoid same frames collapse\n"
|
47
|
-
" into single frame, but this is slower."
|
48
|
-
)
|
49
36
|
|
50
37
|
YUV_RGB_MATRIX = np.array(
|
51
38
|
[
|
@@ -197,8 +184,6 @@ class StickerConvert:
|
|
197
184
|
self.result_step: Optional[int] = None
|
198
185
|
|
199
186
|
self.apngasm = None
|
200
|
-
self.msg_pywebp_dupframe_displayed = False
|
201
|
-
self.msg_webp_pil_dupframe_displayed = False
|
202
187
|
|
203
188
|
@staticmethod
|
204
189
|
def convert(
|
@@ -445,19 +430,37 @@ class StickerConvert:
|
|
445
430
|
and im.n_frames != 0
|
446
431
|
and self.codec_info_orig.fps != 0.0
|
447
432
|
):
|
433
|
+
# Pillow is not reliable for getting webp frame durations
|
434
|
+
durations: Optional[List[int]]
|
435
|
+
if im.format == "WEBP":
|
436
|
+
_, _, _, durations = CodecInfo._get_file_fps_frames_duration_webp(
|
437
|
+
self.in_f
|
438
|
+
)
|
439
|
+
else:
|
440
|
+
durations = None
|
441
|
+
|
448
442
|
duration_ptr = 0.0
|
449
443
|
duration_inc = 1 / self.codec_info_orig.fps * 1000
|
450
|
-
next_frame_start_duration = im.info.get("duration", 1000)
|
451
444
|
frame = 0
|
445
|
+
if durations is None:
|
446
|
+
next_frame_start_duration = cast(int, im.info.get("duration", 1000))
|
447
|
+
else:
|
448
|
+
next_frame_start_duration = durations[0]
|
452
449
|
while True:
|
453
450
|
self.frames_raw.append(np.asarray(im.convert("RGBA")))
|
454
451
|
duration_ptr += duration_inc
|
455
452
|
if duration_ptr >= next_frame_start_duration:
|
453
|
+
frame += 1
|
456
454
|
if frame == im.n_frames:
|
457
455
|
break
|
458
456
|
im.seek(frame)
|
459
|
-
|
460
|
-
|
457
|
+
|
458
|
+
if durations is None:
|
459
|
+
next_frame_start_duration += cast(
|
460
|
+
int, im.info.get("duration", 1000)
|
461
|
+
)
|
462
|
+
else:
|
463
|
+
next_frame_start_duration += durations[frame]
|
461
464
|
else:
|
462
465
|
self.frames_raw.append(np.asarray(im.convert("RGBA")))
|
463
466
|
|
@@ -698,11 +701,9 @@ class StickerConvert:
|
|
698
701
|
self._frames_export_apng()
|
699
702
|
else:
|
700
703
|
self._frames_export_png()
|
701
|
-
elif self.out_f.suffix == ".webp":
|
702
|
-
self._frames_export_webp()
|
703
704
|
elif self.out_f.suffix == ".gif":
|
704
705
|
self._frames_export_pil_anim()
|
705
|
-
elif self.out_f.suffix in (".webm", ".mp4", ".mkv") or is_animated:
|
706
|
+
elif self.out_f.suffix in (".webm", ".mp4", ".mkv", ".webp") or is_animated:
|
706
707
|
self._frames_export_pyav()
|
707
708
|
else:
|
708
709
|
self._frames_export_pil()
|
@@ -719,46 +720,6 @@ class StickerConvert:
|
|
719
720
|
|
720
721
|
return False
|
721
722
|
|
722
|
-
def _frames_export_webp(self) -> None:
|
723
|
-
# TODO: Encode webp with pyav when available
|
724
|
-
# https://github.com/PyAV-Org/PyAV/issues/1352
|
725
|
-
has_dup_frames = self._check_dup()
|
726
|
-
if self.fps:
|
727
|
-
# It was noted that pywebp would collapse all frames.
|
728
|
-
# aed005b attempted to fix this by creating webp with
|
729
|
-
# variable frame duration. However, the webp created would
|
730
|
-
# not be accepted by WhatsApp.
|
731
|
-
# Therefore, we are preferring Pillow over pywebp.
|
732
|
-
if has_dup_frames:
|
733
|
-
if self.opt_comp.force_pywebp:
|
734
|
-
if not self.msg_pywebp_dupframe_displayed:
|
735
|
-
self.cb.put(
|
736
|
-
MSG_PYWEBP_DUPFRAME.format(
|
737
|
-
self.in_f_name, MSG_PYWEBP_FLAG_SET
|
738
|
-
)
|
739
|
-
)
|
740
|
-
self.msg_pywebp_dupframe_displayed = True
|
741
|
-
self._frames_export_pywebp()
|
742
|
-
elif not PIL_WEBP_ANIM:
|
743
|
-
if not self.msg_pywebp_dupframe_displayed:
|
744
|
-
self.cb.put(
|
745
|
-
MSG_PYWEBP_DUPFRAME.format(
|
746
|
-
self.in_f_name, MSG_PYWEBP_NO_LIBWEBP
|
747
|
-
)
|
748
|
-
)
|
749
|
-
self.msg_pywebp_dupframe_displayed = True
|
750
|
-
self._frames_export_pywebp()
|
751
|
-
else:
|
752
|
-
# Warn that using Pillow is slower
|
753
|
-
if not self.msg_webp_pil_dupframe_displayed:
|
754
|
-
self.cb.put(MSG_WEBP_PIL_DUPFRAME.format(self.in_f_name))
|
755
|
-
self.msg_webp_pil_dupframe_displayed = True
|
756
|
-
self._frames_export_pil_anim()
|
757
|
-
else:
|
758
|
-
self._frames_export_pywebp()
|
759
|
-
else:
|
760
|
-
self._frames_export_pil()
|
761
|
-
|
762
723
|
def _frames_export_pil(self) -> None:
|
763
724
|
with Image.fromarray(self.frames_processed[0]) as im: # type: ignore
|
764
725
|
im.save(
|
@@ -771,30 +732,38 @@ class StickerConvert:
|
|
771
732
|
import av
|
772
733
|
from av.video.stream import VideoStream
|
773
734
|
|
774
|
-
|
735
|
+
options_container: Dict[str, str] = {}
|
736
|
+
options_stream: Dict[str, str] = {}
|
775
737
|
|
776
738
|
if isinstance(self.quality, int):
|
777
739
|
# Seems not actually working
|
778
|
-
|
779
|
-
|
740
|
+
options_stream["quality"] = str(self.quality)
|
741
|
+
options_stream["lossless"] = "0"
|
780
742
|
|
781
743
|
if self.out_f.suffix in (".apng", ".png"):
|
782
744
|
codec = "apng"
|
783
745
|
pixel_format = "rgba"
|
784
|
-
|
746
|
+
options_stream["plays"] = "0"
|
785
747
|
elif self.out_f.suffix in (".webm", ".mkv"):
|
786
748
|
codec = "libvpx-vp9"
|
787
749
|
pixel_format = "yuva420p"
|
788
|
-
|
750
|
+
options_stream["loop"] = "0"
|
751
|
+
elif self.out_f.suffix == ".webp":
|
752
|
+
codec = "webp"
|
753
|
+
pixel_format = "yuva420p"
|
754
|
+
options_container["loop"] = "0"
|
789
755
|
else:
|
790
756
|
codec = "libvpx-vp9"
|
791
757
|
pixel_format = "yuv420p"
|
792
|
-
|
758
|
+
options_stream["loop"] = "0"
|
793
759
|
|
794
760
|
with av.open(
|
795
|
-
self.tmp_f,
|
761
|
+
self.tmp_f,
|
762
|
+
"w",
|
763
|
+
format=self.out_f.suffix.replace(".", ""),
|
764
|
+
options=options_container,
|
796
765
|
) as output:
|
797
|
-
out_stream = output.add_stream(codec, rate=self.fps, options=
|
766
|
+
out_stream = output.add_stream(codec, rate=self.fps, options=options_stream)
|
798
767
|
out_stream = cast(VideoStream, out_stream)
|
799
768
|
assert isinstance(self.res_w, int) and isinstance(self.res_h, int)
|
800
769
|
out_stream.width = self.res_w
|
@@ -858,21 +827,6 @@ class StickerConvert:
|
|
858
827
|
**extra_kwargs,
|
859
828
|
)
|
860
829
|
|
861
|
-
def _frames_export_pywebp(self) -> None:
|
862
|
-
import webp # type: ignore
|
863
|
-
|
864
|
-
assert self.fps
|
865
|
-
|
866
|
-
config = webp.WebPConfig.new(quality=self.quality) # type: ignore
|
867
|
-
enc = webp.WebPAnimEncoder.new(self.res_w, self.res_h) # type: ignore
|
868
|
-
timestamp_ms = 0
|
869
|
-
for frame in self.frames_processed:
|
870
|
-
pic = webp.WebPPicture.from_numpy(frame) # type: ignore
|
871
|
-
enc.encode_frame(pic, timestamp_ms, config=config) # type: ignore
|
872
|
-
timestamp_ms += int(1000 / self.fps)
|
873
|
-
anim_data = enc.assemble(timestamp_ms) # type: ignore
|
874
|
-
self.tmp_f.write(anim_data.buffer()) # type: ignore
|
875
|
-
|
876
830
|
def _frames_export_png(self) -> None:
|
877
831
|
with Image.fromarray(self.frames_processed[0], "RGBA") as image: # type: ignore
|
878
832
|
image_quant = self.quantize(image)
|
sticker_convert/gui.py
CHANGED
@@ -135,7 +135,6 @@ class GUI(Window):
|
|
135
135
|
self.fake_vid_var = BooleanVar()
|
136
136
|
self.scale_filter_var = StringVar(self)
|
137
137
|
self.quantize_method_var = StringVar(self)
|
138
|
-
self.force_pywebp_var = BooleanVar()
|
139
138
|
self.cache_dir_var = StringVar(self)
|
140
139
|
self.default_emoji_var = StringVar(self)
|
141
140
|
self.steps_var = IntVar(self)
|
@@ -526,7 +525,6 @@ class GUI(Window):
|
|
526
525
|
fake_vid=self.fake_vid_var.get(),
|
527
526
|
scale_filter=self.scale_filter_var.get(),
|
528
527
|
quantize_method=self.quantize_method_var.get(),
|
529
|
-
force_pywebp=self.force_pywebp_var.get(),
|
530
528
|
cache_dir=self.cache_dir_var.get()
|
531
529
|
if self.cache_dir_var.get() != ""
|
532
530
|
else None,
|
@@ -135,7 +135,6 @@ class CompFrame(LabelFrame):
|
|
135
135
|
self.gui.fake_vid_var.set(preset.get("fake_vid"))
|
136
136
|
self.gui.scale_filter_var.set(preset.get("scale_filter"))
|
137
137
|
self.gui.quantize_method_var.set(preset.get("quantize_method"))
|
138
|
-
self.gui.force_pywebp_var.set(preset.get("force_pywebp"))
|
139
138
|
self.gui.default_emoji_var.set(preset.get("default_emoji"))
|
140
139
|
self.gui.steps_var.set(preset.get("steps"))
|
141
140
|
|
@@ -293,18 +293,6 @@ class AdvancedCompressionWindow(BaseWindow):
|
|
293
293
|
bootstyle="secondary", # type: ignore
|
294
294
|
)
|
295
295
|
|
296
|
-
self.force_pywebp_help_btn = self.add_help_btn(
|
297
|
-
self.gui.help["comp"]["force_pywebp"]
|
298
|
-
)
|
299
|
-
self.force_pywebp_lbl = Label(self.frame_advcomp, text="Force pywebp")
|
300
|
-
self.force_pywebp_cbox = Checkbutton(
|
301
|
-
self.frame_advcomp,
|
302
|
-
variable=self.gui.force_pywebp_var,
|
303
|
-
onvalue=True,
|
304
|
-
offvalue=False,
|
305
|
-
bootstyle="success-round-toggle", # type: ignore
|
306
|
-
)
|
307
|
-
|
308
296
|
self.cache_dir_help_btn = self.add_help_btn(self.gui.help["comp"]["cache_dir"])
|
309
297
|
self.cache_dir_lbl = Label(self.frame_advcomp, text="Custom cache directory")
|
310
298
|
self.cache_dir_entry = Entry(
|
@@ -424,10 +412,6 @@ class AdvancedCompressionWindow(BaseWindow):
|
|
424
412
|
column=2, row=r, columnspan=4, sticky="nes", padx=3, pady=3
|
425
413
|
)
|
426
414
|
r += 1
|
427
|
-
self.force_pywebp_help_btn.grid(column=0, row=r, sticky="w", padx=3, pady=3)
|
428
|
-
self.force_pywebp_lbl.grid(column=1, row=r, sticky="w", padx=3, pady=3)
|
429
|
-
self.force_pywebp_cbox.grid(column=6, row=r, sticky="nes", padx=3, pady=3)
|
430
|
-
r += 1
|
431
415
|
self.cache_dir_help_btn.grid(column=0, row=r, sticky="w", padx=3, pady=3)
|
432
416
|
self.cache_dir_lbl.grid(column=1, row=r, sticky="w", padx=3, pady=3)
|
433
417
|
self.cache_dir_entry.grid(
|
sticker_convert/job_option.py
CHANGED
@@ -74,7 +74,6 @@ class CompOption(BaseOption):
|
|
74
74
|
steps: int = 1
|
75
75
|
fake_vid: Optional[bool] = None
|
76
76
|
quantize_method: Optional[str] = None
|
77
|
-
force_pywebp: Optional[bool] = None
|
78
77
|
scale_filter: Optional[str] = None
|
79
78
|
cache_dir: Optional[str] = None
|
80
79
|
default_emoji: str = "😀"
|
@@ -44,7 +44,6 @@
|
|
44
44
|
"fake_vid": false,
|
45
45
|
"scale_filter": "bicubic",
|
46
46
|
"quantize_method": "imagequant",
|
47
|
-
"force_pywebp": false,
|
48
47
|
"default_emoji": "😀"
|
49
48
|
},
|
50
49
|
"signal": {
|
@@ -92,7 +91,6 @@
|
|
92
91
|
"fake_vid": false,
|
93
92
|
"scale_filter": "bicubic",
|
94
93
|
"quantize_method": "imagequant",
|
95
|
-
"force_pywebp": false,
|
96
94
|
"default_emoji": "😀"
|
97
95
|
},
|
98
96
|
"telegram": {
|
@@ -140,7 +138,6 @@
|
|
140
138
|
"fake_vid": false,
|
141
139
|
"scale_filter": "bicubic",
|
142
140
|
"quantize_method": "imagequant",
|
143
|
-
"force_pywebp": false,
|
144
141
|
"default_emoji": "😀"
|
145
142
|
},
|
146
143
|
"telegram_emoji": {
|
@@ -188,7 +185,6 @@
|
|
188
185
|
"fake_vid": false,
|
189
186
|
"scale_filter": "bicubic",
|
190
187
|
"quantize_method": "imagequant",
|
191
|
-
"force_pywebp": false,
|
192
188
|
"default_emoji": "😀"
|
193
189
|
},
|
194
190
|
"whatsapp": {
|
@@ -236,7 +232,6 @@
|
|
236
232
|
"fake_vid": true,
|
237
233
|
"scale_filter": "bicubic",
|
238
234
|
"quantize_method": "imagequant",
|
239
|
-
"force_pywebp": false,
|
240
235
|
"default_emoji": "😀"
|
241
236
|
},
|
242
237
|
"line": {
|
@@ -284,7 +279,6 @@
|
|
284
279
|
"fake_vid": false,
|
285
280
|
"scale_filter": "bicubic",
|
286
281
|
"quantize_method": "imagequant",
|
287
|
-
"force_pywebp": false,
|
288
282
|
"default_emoji": "😀"
|
289
283
|
},
|
290
284
|
"kakao": {
|
@@ -332,7 +326,6 @@
|
|
332
326
|
"fake_vid": false,
|
333
327
|
"scale_filter": "bicubic",
|
334
328
|
"quantize_method": "imagequant",
|
335
|
-
"force_pywebp": false,
|
336
329
|
"default_emoji": "😀"
|
337
330
|
},
|
338
331
|
"viber": {
|
@@ -380,7 +373,6 @@
|
|
380
373
|
"fake_vid": false,
|
381
374
|
"scale_filter": "bicubic",
|
382
375
|
"quantize_method": "imagequant",
|
383
|
-
"force_pywebp": false,
|
384
376
|
"default_emoji": "😀"
|
385
377
|
},
|
386
378
|
"imessage_small": {
|
@@ -428,7 +420,6 @@
|
|
428
420
|
"fake_vid": false,
|
429
421
|
"scale_filter": "bicubic",
|
430
422
|
"quantize_method": "imagequant",
|
431
|
-
"force_pywebp": false,
|
432
423
|
"default_emoji": "😀"
|
433
424
|
},
|
434
425
|
"imessage_medium": {
|
@@ -476,7 +467,6 @@
|
|
476
467
|
"fake_vid": false,
|
477
468
|
"scale_filter": "bicubic",
|
478
469
|
"quantize_method": "imagequant",
|
479
|
-
"force_pywebp": false,
|
480
470
|
"default_emoji": "😀"
|
481
471
|
},
|
482
472
|
"imessage_large": {
|
@@ -524,7 +514,6 @@
|
|
524
514
|
"fake_vid": false,
|
525
515
|
"scale_filter": "bicubic",
|
526
516
|
"quantize_method": "imagequant",
|
527
|
-
"force_pywebp": false,
|
528
517
|
"default_emoji": "😀"
|
529
518
|
},
|
530
519
|
"custom": {
|
@@ -572,7 +561,6 @@
|
|
572
561
|
"fake_vid": false,
|
573
562
|
"scale_filter": "bicubic",
|
574
563
|
"quantize_method": "imagequant",
|
575
|
-
"force_pywebp": false,
|
576
564
|
"default_emoji": "😀"
|
577
565
|
}
|
578
566
|
}
|
@@ -51,7 +51,6 @@
|
|
51
51
|
"fake_vid": "Convert (faking) image to video.\nUseful if:\n(1) Size limit for video is larger than image;\n(2) Mix image and video into same pack.",
|
52
52
|
"scale_filter": "Set scale filter. Default as bicubic. Valid options are:\n- nearest = Use nearest neighbour (Suitable for pixel art)\n- box = Similar to nearest, but better downscaling\n- bilinear = Linear interpolation\n- hamming = Similar to bilinear, but better downscaling\n- bicubic = Cubic spline interpolation\n- lanczos = A high-quality downsampling filter",
|
53
53
|
"quantize_method": "Set method for quantizing image. Default as imagequant. Valid options are:\n- imagequant = Best quality but slow\n- fastoctree = Fast but image looks chunky\n- none = No image quantizing, large image size as result",
|
54
|
-
"force_pywebp": "Force using pywebp for encoding webp files instead of Pillow.",
|
55
54
|
"cache_dir": "Set custom cache directory.\nUseful for debugging, or speed up conversion if cache_dir is on RAM disk.",
|
56
55
|
"default_emoji": "Set the default emoji for uploading Signal and Telegram sticker packs."
|
57
56
|
},
|
@@ -80,9 +80,9 @@ class CodecInfo:
|
|
80
80
|
@staticmethod
|
81
81
|
def get_file_fps_frames_duration(
|
82
82
|
file: Union[Path, bytes], file_ext: Optional[str] = None
|
83
|
-
) -> Tuple[float, int,
|
83
|
+
) -> Tuple[float, int, int]:
|
84
84
|
fps: float
|
85
|
-
duration:
|
85
|
+
duration: int
|
86
86
|
|
87
87
|
if not file_ext and isinstance(file, Path):
|
88
88
|
file_ext = CodecInfo.get_file_ext(file)
|
@@ -94,7 +94,9 @@ class CodecInfo:
|
|
94
94
|
else:
|
95
95
|
duration = 0
|
96
96
|
elif file_ext == ".webp":
|
97
|
-
fps, frames, duration = CodecInfo._get_file_fps_frames_duration_webp(
|
97
|
+
fps, frames, duration, _ = CodecInfo._get_file_fps_frames_duration_webp(
|
98
|
+
file
|
99
|
+
)
|
98
100
|
elif file_ext in (".gif", ".apng", ".png"):
|
99
101
|
fps, frames, duration = CodecInfo._get_file_fps_frames_duration_pillow(file)
|
100
102
|
else:
|
@@ -115,7 +117,7 @@ class CodecInfo:
|
|
115
117
|
if file_ext == ".tgs":
|
116
118
|
return CodecInfo._get_file_fps_tgs(file)
|
117
119
|
elif file_ext == ".webp":
|
118
|
-
fps, _, _ = CodecInfo._get_file_fps_frames_duration_webp(file)
|
120
|
+
fps, _, _, _ = CodecInfo._get_file_fps_frames_duration_webp(file)
|
119
121
|
return fps
|
120
122
|
elif file_ext in (".gif", ".apng", ".png"):
|
121
123
|
fps, _, _ = CodecInfo._get_file_fps_frames_duration_pillow(file)
|
@@ -159,8 +161,8 @@ class CodecInfo:
|
|
159
161
|
@staticmethod
|
160
162
|
def get_file_duration(
|
161
163
|
file: Union[Path, bytes], file_ext: Optional[str] = None
|
162
|
-
) ->
|
163
|
-
duration:
|
164
|
+
) -> int:
|
165
|
+
duration: int
|
164
166
|
|
165
167
|
# Return duration in miliseconds
|
166
168
|
if not file_ext and isinstance(file, Path):
|
@@ -173,7 +175,7 @@ class CodecInfo:
|
|
173
175
|
else:
|
174
176
|
duration = 0
|
175
177
|
elif file_ext == ".webp":
|
176
|
-
_, _, duration = CodecInfo._get_file_fps_frames_duration_webp(file)
|
178
|
+
_, _, duration, _ = CodecInfo._get_file_fps_frames_duration_webp(file)
|
177
179
|
elif file_ext in (".gif", ".png", ".apng"):
|
178
180
|
_, _, duration = CodecInfo._get_file_fps_frames_duration_pillow(file)
|
179
181
|
else:
|
@@ -233,9 +235,9 @@ class CodecInfo:
|
|
233
235
|
@staticmethod
|
234
236
|
def _get_file_fps_frames_duration_pillow(
|
235
237
|
file: Union[Path, bytes], frames_only: bool = False
|
236
|
-
) -> Tuple[float, int,
|
237
|
-
total_duration = 0
|
238
|
-
durations: List[
|
238
|
+
) -> Tuple[float, int, int]:
|
239
|
+
total_duration = 0
|
240
|
+
durations: List[int] = []
|
239
241
|
|
240
242
|
with Image.open(file) as im:
|
241
243
|
if "n_frames" in dir(im):
|
@@ -244,7 +246,7 @@ class CodecInfo:
|
|
244
246
|
return 0.0, frames, 1
|
245
247
|
for i in range(im.n_frames):
|
246
248
|
im.seek(i)
|
247
|
-
frame_duration = cast(
|
249
|
+
frame_duration = cast(int, im.info.get("duration", 1000))
|
248
250
|
if frame_duration not in durations and frame_duration != 0:
|
249
251
|
durations.append(frame_duration)
|
250
252
|
total_duration += frame_duration
|
@@ -255,7 +257,7 @@ class CodecInfo:
|
|
255
257
|
else:
|
256
258
|
duration_gcd = durations_gcd(*durations)
|
257
259
|
frames_apparent = total_duration / duration_gcd
|
258
|
-
fps = frames_apparent / total_duration * 1000
|
260
|
+
fps = float(frames_apparent / total_duration * 1000)
|
259
261
|
return fps, frames, total_duration
|
260
262
|
|
261
263
|
return 0.0, 1, 0
|
@@ -263,10 +265,11 @@ class CodecInfo:
|
|
263
265
|
@staticmethod
|
264
266
|
def _get_file_fps_frames_duration_webp(
|
265
267
|
file: Union[Path, bytes],
|
266
|
-
) -> Tuple[float, int, int]:
|
268
|
+
) -> Tuple[float, int, int, List[int]]:
|
267
269
|
total_duration = 0
|
268
270
|
frames = 0
|
269
271
|
durations: List[int] = []
|
272
|
+
durations_unique: List[int] = []
|
270
273
|
|
271
274
|
def _open_f(file: Union[Path, bytes]) -> BinaryIO:
|
272
275
|
if isinstance(file, Path):
|
@@ -285,22 +288,23 @@ class CodecInfo:
|
|
285
288
|
int(frame_duration_32[-1]) & 0b11111100
|
286
289
|
)
|
287
290
|
frame_duration = int.from_bytes(frame_duration_bytes, "little")
|
288
|
-
if frame_duration not in
|
289
|
-
|
291
|
+
if frame_duration not in durations_unique and frame_duration != 0:
|
292
|
+
durations_unique.append(frame_duration)
|
293
|
+
durations.append(frame_duration)
|
290
294
|
total_duration += frame_duration
|
291
295
|
frames += 1
|
292
296
|
|
293
297
|
if frames <= 1:
|
294
|
-
return 0.0, 1, 0
|
298
|
+
return 0.0, 1, 0, durations
|
295
299
|
|
296
|
-
if len(
|
300
|
+
if len(durations_unique) == 1:
|
297
301
|
fps = frames / total_duration * 1000
|
298
302
|
else:
|
299
|
-
duration_gcd = durations_gcd(*
|
303
|
+
duration_gcd = durations_gcd(*durations_unique)
|
300
304
|
frames_apparent = total_duration / duration_gcd
|
301
305
|
fps = float(frames_apparent / total_duration * 1000)
|
302
306
|
|
303
|
-
return fps, frames, total_duration
|
307
|
+
return fps, frames, total_duration, durations
|
304
308
|
|
305
309
|
@staticmethod
|
306
310
|
def _get_file_frames_duration_av(
|
sticker_convert/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sticker-convert
|
3
|
-
Version: 2.8.
|
3
|
+
Version: 2.8.11
|
4
4
|
Summary: Convert (animated) stickers to/from WhatsApp, Telegram, Signal, Line, Kakao, Viber, iMessage. Written in Python.
|
5
5
|
Author-email: laggykiller <chaudominic2@gmail.com>
|
6
6
|
Maintainer-email: laggykiller <chaudominic2@gmail.com>
|
@@ -365,9 +365,9 @@ Requires-Python: >=3.8
|
|
365
365
|
Description-Content-Type: text/markdown
|
366
366
|
License-File: LICENSE
|
367
367
|
Requires-Dist: aiolimiter ~=1.1.0
|
368
|
-
Requires-Dist: anyio ~=4.
|
369
|
-
Requires-Dist: apngasm-python ~=1.
|
370
|
-
Requires-Dist: av ~=12.
|
368
|
+
Requires-Dist: anyio ~=4.4.0
|
369
|
+
Requires-Dist: apngasm-python ~=1.3.1
|
370
|
+
Requires-Dist: av ~=12.1.0
|
371
371
|
Requires-Dist: beautifulsoup4 ~=4.12.3
|
372
372
|
Requires-Dist: rookiepy ~=0.5.1
|
373
373
|
Requires-Dist: imagequant ~=1.1.1
|
@@ -376,14 +376,13 @@ Requires-Dist: mergedeep ~=1.3.4
|
|
376
376
|
Requires-Dist: numpy >=1.22.4
|
377
377
|
Requires-Dist: Pillow ~=10.3.0
|
378
378
|
Requires-Dist: pyoxipng ~=9.0.0
|
379
|
-
Requires-Dist: python-telegram-bot ~=21.
|
380
|
-
Requires-Dist: requests ~=2.
|
379
|
+
Requires-Dist: python-telegram-bot ~=21.2
|
380
|
+
Requires-Dist: requests ~=2.32.2
|
381
381
|
Requires-Dist: rlottie-python ~=1.3.4
|
382
382
|
Requires-Dist: signalstickers-client-fork-laggykiller ~=3.3.0.post1
|
383
383
|
Requires-Dist: sqlcipher3-wheels ~=0.5.2.post1
|
384
384
|
Requires-Dist: tqdm ~=4.66.4
|
385
385
|
Requires-Dist: ttkbootstrap-fork-laggykiller ~=1.5.1
|
386
|
-
Requires-Dist: webp ~=0.3.0
|
387
386
|
|
388
387
|
# sticker-convert
|
389
388
|

|
@@ -479,22 +478,28 @@ Requires-Dist: webp ~=0.3.0
|
|
479
478
|
To run in CLI mode, pass on any arguments
|
480
479
|
|
481
480
|
```
|
482
|
-
usage: sticker-convert.py [-h] [--version] [--no-confirm] [--no-progress] [--custom-presets CUSTOM_PRESETS]
|
481
|
+
usage: sticker-convert.py [-h] [--version] [--no-confirm] [--no-progress] [--custom-presets CUSTOM_PRESETS]
|
482
|
+
[--input-dir INPUT_DIR]
|
483
483
|
[--download-auto DOWNLOAD_AUTO | --download-signal DOWNLOAD_SIGNAL | --download-telegram DOWNLOAD_TELEGRAM | --download-line DOWNLOAD_LINE | --download-kakao DOWNLOAD_KAKAO | --download-viber DOWNLOAD_VIBER]
|
484
484
|
[--output-dir OUTPUT_DIR] [--author AUTHOR] [--title TITLE]
|
485
|
-
[--export-signal | --export-telegram | --export-telegram-emoji | --export-whatsapp | --export-imessage]
|
485
|
+
[--export-signal | --export-telegram | --export-telegram-emoji | --export-whatsapp | --export-imessage]
|
486
|
+
[--no-compress]
|
486
487
|
[--preset {auto,signal,telegram,telegram_emoji,whatsapp,line,kakao,viber,imessage_small,imessage_medium,imessage_large,custom}]
|
487
|
-
[--steps STEPS] [--processes PROCESSES] [--fps-min FPS_MIN] [--fps-max FPS_MAX]
|
488
|
-
[--
|
489
|
-
[--res-
|
490
|
-
[--
|
491
|
-
[--
|
492
|
-
[--
|
493
|
-
[--
|
494
|
-
[--
|
495
|
-
[--
|
496
|
-
[--
|
497
|
-
[--
|
488
|
+
[--steps STEPS] [--processes PROCESSES] [--fps-min FPS_MIN] [--fps-max FPS_MAX]
|
489
|
+
[--fps-power FPS_POWER] [--res-min RES_MIN] [--res-max RES_MAX] [--res-w-min RES_W_MIN]
|
490
|
+
[--res-w-max RES_W_MAX] [--res-h-min RES_H_MIN] [--res-h-max RES_H_MAX] [--res-power RES_POWER]
|
491
|
+
[--quality-min QUALITY_MIN] [--quality-max QUALITY_MAX] [--quality-power QUALITY_POWER]
|
492
|
+
[--color-min COLOR_MIN] [--color-max COLOR_MAX] [--color-power COLOR_POWER]
|
493
|
+
[--duration-min DURATION_MIN] [--duration-max DURATION_MAX] [--padding-percent PADDING_PERCENT]
|
494
|
+
[--bg-color BG_COLOR] [--vid-size-max VID_SIZE_MAX] [--img-size-max IMG_SIZE_MAX]
|
495
|
+
[--vid-format VID_FORMAT] [--img-format IMG_FORMAT] [--fake-vid] [--scale-filter SCALE_FILTER]
|
496
|
+
[--quantize-method QUANTIZE_METHOD] [--cache-dir CACHE_DIR] [--default-emoji DEFAULT_EMOJI]
|
497
|
+
[--signal-uuid SIGNAL_UUID] [--signal-password SIGNAL_PASSWORD] [--signal-get-auth]
|
498
|
+
[--signal-data-dir SIGNAL_DATA_DIR] [--telegram-token TELEGRAM_TOKEN]
|
499
|
+
[--telegram-userid TELEGRAM_USERID] [--kakao-auth-token KAKAO_AUTH_TOKEN] [--kakao-get-auth]
|
500
|
+
[--kakao-username KAKAO_USERNAME] [--kakao-password KAKAO_PASSWORD]
|
501
|
+
[--kakao-country-code KAKAO_COUNTRY_CODE] [--kakao-phone-number KAKAO_PHONE_NUMBER]
|
502
|
+
[--line-get-auth] [--line-cookies LINE_COOKIES] [--save-cred SAVE_CRED]
|
498
503
|
|
499
504
|
CLI for stickers-convert
|
500
505
|
|
@@ -620,7 +625,6 @@ Compression options:
|
|
620
625
|
- imagequant = Best quality but slow
|
621
626
|
- fastoctree = Fast but image looks chunky
|
622
627
|
- none = No image quantizing, large image size as result
|
623
|
-
--force-pywebp Force using pywebp for encoding webp files instead of Pillow.
|
624
628
|
--cache-dir CACHE_DIR
|
625
629
|
Set custom cache directory.
|
626
630
|
Useful for debugging, or speed up conversion if cache_dir is on RAM disk.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
sticker_convert/__init__.py,sha256=iQnv6UOOA69c3soAn7ZOnAIubTIQSUxtq1Uhh8xRWvU,102
|
2
2
|
sticker_convert/__main__.py,sha256=6RJauR-SCSSTT3TU7FFB6B6PVwsCxO2xZXtmZ3jc2Is,463
|
3
|
-
sticker_convert/cli.py,sha256=
|
4
|
-
sticker_convert/converter.py,sha256=
|
3
|
+
sticker_convert/cli.py,sha256=DUPaI0Vw-a63TxxC2SSskLd1PlAuQtFOklggMo04IJc,18854
|
4
|
+
sticker_convert/converter.py,sha256=XMiYzIzlcdvx_AFyyk7j-Zdyj3ablLFJFUZ6tjrlGIs,35861
|
5
5
|
sticker_convert/definitions.py,sha256=ZhP2ALCEud-w9ZZD4c3TDG9eHGPZyaAL7zPUsJAbjtE,2073
|
6
|
-
sticker_convert/gui.py,sha256=
|
6
|
+
sticker_convert/gui.py,sha256=TRPGwMhSMPHnZppHmw2OWHKTJtGoeLpGWD0eRYi4_yk,30707
|
7
7
|
sticker_convert/job.py,sha256=vKv1--y4MVmZV_IBpUhEfNEiUeEqrTR1umzlALPXKdw,25775
|
8
|
-
sticker_convert/job_option.py,sha256=
|
9
|
-
sticker_convert/version.py,sha256=
|
8
|
+
sticker_convert/job_option.py,sha256=JHAFCxp7-dDwD-1PbpYLAFRF3OoJu8cj_BjOm5r8Gp8,7732
|
9
|
+
sticker_convert/version.py,sha256=oxsRvN-1re7LUAQn0GzovVDlajKtGywZotOzD3vzeIE,47
|
10
10
|
sticker_convert/downloaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
sticker_convert/downloaders/download_base.py,sha256=x18bI2mPpbXRnSmStBHEb1IvN-VPCilOHLQUs6YPUEU,4041
|
12
12
|
sticker_convert/downloaders/download_kakao.py,sha256=UFp7EpMea62fIePY5DfhH4jThAwdeazfoC5iW1g4dAo,8516
|
@@ -17,7 +17,7 @@ sticker_convert/downloaders/download_viber.py,sha256=mrM1XIuXuon4hlkYQc8vYqjYr1K
|
|
17
17
|
sticker_convert/gui_components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
sticker_convert/gui_components/gui_utils.py,sha256=okho2cA1Scem_m6rPiYifreFzpFrM21-yUkiAv64EUI,3431
|
19
19
|
sticker_convert/gui_components/frames/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
sticker_convert/gui_components/frames/comp_frame.py,sha256=
|
20
|
+
sticker_convert/gui_components/frames/comp_frame.py,sha256=9k_UntKKi2G_g0byzoj1rdTqOq7q9mcnXiy799bYnr0,7257
|
21
21
|
sticker_convert/gui_components/frames/config_frame.py,sha256=b3X4QAnGpde0OhthXHmjSyU_Yb5tYRUFXmy04Yi8Zmo,4316
|
22
22
|
sticker_convert/gui_components/frames/control_frame.py,sha256=_XiOJ9JPUfiysDghGG04sEVLrXG9TMVlDZ60W0LhYVI,835
|
23
23
|
sticker_convert/gui_components/frames/cred_frame.py,sha256=I3XrOv7kUOsvFWquuzWWpZWbLclqKQXgD7dx5pcTuY4,6499
|
@@ -26,7 +26,7 @@ sticker_convert/gui_components/frames/output_frame.py,sha256=n2WLk22h61DoZli8WbF
|
|
26
26
|
sticker_convert/gui_components/frames/progress_frame.py,sha256=LWUZg_iL7iiNTfu7N5Ct_pklZdghxihENi7DP9YozOE,4915
|
27
27
|
sticker_convert/gui_components/frames/right_clicker.py,sha256=dGIvSzEChrkguR80pzUemBNJ39uzJjVJQKeDNUoW3Gk,721
|
28
28
|
sticker_convert/gui_components/windows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
sticker_convert/gui_components/windows/advanced_compression_window.py,sha256=
|
29
|
+
sticker_convert/gui_components/windows/advanced_compression_window.py,sha256=DT5SgSWWKXRbOD8fJK-9kch9U_P1N3ox6-bphlPr0Ss,31964
|
30
30
|
sticker_convert/gui_components/windows/base_window.py,sha256=xBE1peGMPvWsdrFej0CJUVhmQ57GJGvz-cX03nIIhkE,1108
|
31
31
|
sticker_convert/gui_components/windows/kakao_get_auth_window.py,sha256=AvXB2Q8pAPkKILHTvlLGV9jfBcvskCA4arko4nvBTdo,7115
|
32
32
|
sticker_convert/gui_components/windows/line_get_auth_window.py,sha256=S4ES_lk2-GDvPokZtYALnUc5zW1VbS4WulNqO9K1aSs,3375
|
@@ -67,9 +67,9 @@ sticker_convert/resources/NotoColorEmoji.ttf,sha256=LurIVaCIA8bSCfjrdO1feYr0bhKL
|
|
67
67
|
sticker_convert/resources/appicon.icns,sha256=FB2DVTOQcFfQNZ9RcyG3z9c9k7eOiI1qw0IJhXMRFg4,5404
|
68
68
|
sticker_convert/resources/appicon.ico,sha256=-ldugcl2Yq2pBRTktnhGKWInpKyWzRjCiPvMr3XPTlc,38078
|
69
69
|
sticker_convert/resources/appicon.png,sha256=6XBEQz7PnerqS43aRkwpWolFG4WvKMuQ-st1ly-_JPg,5265
|
70
|
-
sticker_convert/resources/compression.json,sha256=
|
70
|
+
sticker_convert/resources/compression.json,sha256=8SAv5m7_R2QFaU656W7gpliCJF9ZmGdE_XfnJU3D0ZE,12156
|
71
71
|
sticker_convert/resources/emoji.json,sha256=sXSuKusyG1L2Stuf9BL5ZqfzOIOdeAeE3RXcrXAsLdY,413367
|
72
|
-
sticker_convert/resources/help.json,sha256=
|
72
|
+
sticker_convert/resources/help.json,sha256=9A7zXYrHMkIE75MhDD3xoFuk9jofFRGCVVXH_g_h9bk,6634
|
73
73
|
sticker_convert/resources/input.json,sha256=S3CkInBMLrk5OS9aJfuTCDsf_64NOjNT3IKQr7d1hM0,2665
|
74
74
|
sticker_convert/resources/output.json,sha256=QYP2gqDvEaAm5I9bH4NReaB1XMLboevv69u-V8YdZUs,1373
|
75
75
|
sticker_convert/uploaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -90,12 +90,12 @@ sticker_convert/utils/files/metadata_handler.py,sha256=UVKpwflsXwiVh-F-HNr0Ucrix
|
|
90
90
|
sticker_convert/utils/files/run_bin.py,sha256=QalA9je6liHxiOtxsjsFsIkc2t59quhcJCVpP1X3p50,1743
|
91
91
|
sticker_convert/utils/files/sanitize_filename.py,sha256=HBklPGsHRJjFQUIC5rYTQsUrsuTtezZXIEA8CPhLP8A,2156
|
92
92
|
sticker_convert/utils/media/apple_png_normalize.py,sha256=LbrQhc7LlYX4I9ek4XJsZE4l0MygBA1jB-PFiYLEkzk,3657
|
93
|
-
sticker_convert/utils/media/codec_info.py,sha256=
|
93
|
+
sticker_convert/utils/media/codec_info.py,sha256=1QfW3wgZ5vOk7T4XtLHYvJK1x8RbASRPSvhKEPkcu9A,15747
|
94
94
|
sticker_convert/utils/media/decrypt_kakao.py,sha256=4wq9ZDRnFkx1WmFZnyEogBofiLGsWQM_X69HlA36578,1947
|
95
95
|
sticker_convert/utils/media/format_verify.py,sha256=Xf94jyqk_6M9IlFGMy0wYIgQKn_yg00nD4XW0CgAbew,5732
|
96
|
-
sticker_convert-2.8.
|
97
|
-
sticker_convert-2.8.
|
98
|
-
sticker_convert-2.8.
|
99
|
-
sticker_convert-2.8.
|
100
|
-
sticker_convert-2.8.
|
101
|
-
sticker_convert-2.8.
|
96
|
+
sticker_convert-2.8.11.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
97
|
+
sticker_convert-2.8.11.dist-info/METADATA,sha256=yeRKxmheS7CvSGvQIwZ8-uqxUs7NAL6Ammf3KKBQCYo,50376
|
98
|
+
sticker_convert-2.8.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
99
|
+
sticker_convert-2.8.11.dist-info/entry_points.txt,sha256=MNJ7XyC--ugxi5jS1nzjDLGnxCyLuaGdsVLnJhDHCqs,66
|
100
|
+
sticker_convert-2.8.11.dist-info/top_level.txt,sha256=r9vfnB0l1ZnH5pTH5RvkobnK3Ow9m0RsncaOMAtiAtk,16
|
101
|
+
sticker_convert-2.8.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|