sticker-convert 2.1.14__py3-none-any.whl → 2.1.15__py3-none-any.whl

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.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env python3
2
2
  '''sticker-convert'''
3
- __version__ = '2.1.14'
3
+ __version__ = '2.1.15'
@@ -3,8 +3,10 @@ def main():
3
3
  import multiprocessing
4
4
  import sys
5
5
  import os
6
+ from .__init__ import __version__
6
7
 
7
8
  multiprocessing.freeze_support()
9
+ print(f"sticker-convert {__version__}")
8
10
  script_path = os.path.dirname(__file__)
9
11
  if not os.path.isdir(script_path):
10
12
  script_path = os.path.dirname(sys.argv[0])
@@ -218,8 +218,9 @@ class StickerConvert:
218
218
  self.frames_import_imageio()
219
219
 
220
220
  def frames_import_imageio(self):
221
- if self.in_f_ext in '.webp':
222
- # ffmpeg do not support webp decoding (yet)
221
+ # ffmpeg do not support webp decoding (yet)
222
+ # ffmpeg could fail to decode apng if file is buggy
223
+ if self.in_f_ext in ('.webp', '.apng', 'png'):
223
224
  for frame in iio.imiter(self.in_f, plugin='pillow', mode='RGBA'):
224
225
  self.frames_raw.append(frame)
225
226
  return
@@ -61,4 +61,5 @@ class DirUtils:
61
61
  if (config_dir := DirUtils._get_curr_dir_if_writable()) != None:
62
62
  return config_dir
63
63
  else:
64
+ os.makedirs(fallback_dir, exist_ok=True)
64
65
  return fallback_dir
@@ -75,17 +75,25 @@ class CodecInfo:
75
75
  def get_file_codec(file: str) -> Optional[str]:
76
76
  codec = None
77
77
  try:
78
- codec = Image.open(file).format
78
+ im = Image.open(file)
79
+ codec = im.format
79
80
  except UnidentifiedImageError:
80
81
  pass
81
82
 
82
83
  # Unable to distinguish apng and png
83
- if codec not in (None, 'PNG'):
84
- return codec.lower()
85
- else:
84
+ if codec == None:
86
85
  metadata = iio.immeta(file, plugin="pyav", exclude_applied=False)
87
86
  codec = metadata.get("codec", None)
87
+ if codec == None:
88
+ raise RuntimeError(f"Unable to get codec for file {file}")
88
89
  return codec
90
+ elif codec == "PNG":
91
+ if im.is_animated:
92
+ return "apng"
93
+ else:
94
+ return "png"
95
+ else:
96
+ return codec.lower()
89
97
 
90
98
  @staticmethod
91
99
  def get_file_res(file: str) -> tuple[int, int]:
@@ -95,7 +103,7 @@ class CodecInfo:
95
103
  with LottieAnimation.from_tgs(file) as anim:
96
104
  width, height = anim.lottie_animation_get_size()
97
105
  else:
98
- if file_ext == ".webp":
106
+ if file_ext in (".webp", ".png", ".apng"):
99
107
  plugin = "pillow"
100
108
  else:
101
109
  plugin = "pyav"
@@ -114,7 +122,7 @@ class CodecInfo:
114
122
  with LottieAnimation.from_tgs(file) as anim:
115
123
  frames = anim.lottie_animation_get_totalframe()
116
124
  else:
117
- if file_ext == ".webp":
125
+ if file_ext in (".webp", ".png", ".apng"):
118
126
  frames = Image.open(file).n_frames
119
127
  else:
120
128
  frames = frames = len([* iio.imiter(file, plugin="pyav")])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sticker-convert
3
- Version: 2.1.14
3
+ Version: 2.1.15
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>
@@ -1,7 +1,7 @@
1
- sticker_convert/__init__.py,sha256=2g8vglQqwWVnyH8IyUbZoj1xJpu730PcWHARF3huLrE,67
2
- sticker_convert/__main__.py,sha256=W3n9SprqoDQxaWDAqLVA7DiavMdbPLVdtbASTKSpZS0,546
1
+ sticker_convert/__init__.py,sha256=MpIUsAq6cLwAoV4lwfBAws23Exb-Ul9ygSUlMat2sH4,67
2
+ sticker_convert/__main__.py,sha256=HHzFzRsxxhxkCL15_sE1rBAdtprT0NfVUNR591BMvl4,628
3
3
  sticker_convert/cli.py,sha256=oWOEi1NriUy2ijzd7G0PqHd-c2GQA903CLtQtlYkP8s,16568
4
- sticker_convert/converter.py,sha256=k4wy8nYtUFaEFxQ6QRPWPUyAorGgRIWQ0WLElsnKTXw,16780
4
+ sticker_convert/converter.py,sha256=ovukCtlEWNRDTU2OJ_k19cpUg0nMiuY3CVXTMJhSZ7s,16854
5
5
  sticker_convert/gui.py,sha256=AXNPOgES0lyp-nhc5HRQMTr69xSAeUqEW1ehXCIadt0,27484
6
6
  sticker_convert/job.py,sha256=VEyEW3KV040PbzfPCxUpLU9Im8RVv_hQqGUVBDRz87k,17440
7
7
  sticker_convert/job_option.py,sha256=0W97v-39FFMyFUqIx4f8ClOqQjvnVNdcvS6MbWQA7Jo,10803
@@ -76,17 +76,17 @@ sticker_convert/utils/auth/get_kakao_auth.py,sha256=Q3CxzDqzoo9vf_bsbmpKZXeQODEX
76
76
  sticker_convert/utils/auth/get_line_auth.py,sha256=pKe2N3QLTyB0wWBpkD9rlDBqHK7LZ5hnAmfPH7XVmFI,1211
77
77
  sticker_convert/utils/auth/get_signal_auth.py,sha256=NHGOZEiKkGaJmj58BmR8ynmUsAn_IRzE4jpEHXKUhVM,11874
78
78
  sticker_convert/utils/files/cache_store.py,sha256=lNS6ItZ3lwNa7NipkDo7n0wIoAf728dcRV0r0ohmM3s,730
79
- sticker_convert/utils/files/dir_utils.py,sha256=_jDyyPTVQXiVr4dJhPFaXqaKvch_MWLngwH7eZfezv4,1861
79
+ sticker_convert/utils/files/dir_utils.py,sha256=_dDt3UAisnCyiqWoZsfMIEnX2Mkqz-O4UUWCRR0IWDM,1914
80
80
  sticker_convert/utils/files/json_manager.py,sha256=BBndjSY5kvjxurOpnDI2DRsKoLrNBTf5HoGfUqlf-4Y,503
81
81
  sticker_convert/utils/files/metadata_handler.py,sha256=KIy8j89DMBW7-gpL9jqhzz96GgBvPHsRYegHXemk_mY,8346
82
82
  sticker_convert/utils/files/run_bin.py,sha256=4c8y5c_2wUfm0hbJSOGFcezpW5BVqM5_e9aliPbxvwo,1632
83
83
  sticker_convert/utils/media/apple_png_normalize.py,sha256=YGrZ8pZvgfhw8dW-0gf7XcXk_R82lJTX-oTo6SsB7uY,3719
84
- sticker_convert/utils/media/codec_info.py,sha256=zW_wMAsyZctjQwZVmn63KfUryKNO-LZjOIZrEMuqQeo,4547
84
+ sticker_convert/utils/media/codec_info.py,sha256=rrEcWwpBZwMEifvSdRuSjTVOye_D5vSonqV1OZMs44Y,4834
85
85
  sticker_convert/utils/media/decrypt_kakao.py,sha256=gMz64vIGEIPAl4FFWuUbPMHE7vExr46ZFpzMoukvwws,1918
86
86
  sticker_convert/utils/media/format_verify.py,sha256=7WvvDSFDkyG1WlkXKqVbmPjKiyEedtqivZcCqSNziD8,6179
87
- sticker_convert-2.1.14.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
88
- sticker_convert-2.1.14.dist-info/METADATA,sha256=sFHn2rIUtXak2Ve9wm-23Yo6raPrgE9UtNCDhTUbCxU,44697
89
- sticker_convert-2.1.14.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
- sticker_convert-2.1.14.dist-info/entry_points.txt,sha256=MNJ7XyC--ugxi5jS1nzjDLGnxCyLuaGdsVLnJhDHCqs,66
91
- sticker_convert-2.1.14.dist-info/top_level.txt,sha256=r9vfnB0l1ZnH5pTH5RvkobnK3Ow9m0RsncaOMAtiAtk,16
92
- sticker_convert-2.1.14.dist-info/RECORD,,
87
+ sticker_convert-2.1.15.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
88
+ sticker_convert-2.1.15.dist-info/METADATA,sha256=D1vhJds0tNxpCzpMBgwDLelZxPimaGdLLSKP3yf4ITw,44697
89
+ sticker_convert-2.1.15.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
+ sticker_convert-2.1.15.dist-info/entry_points.txt,sha256=MNJ7XyC--ugxi5jS1nzjDLGnxCyLuaGdsVLnJhDHCqs,66
91
+ sticker_convert-2.1.15.dist-info/top_level.txt,sha256=r9vfnB0l1ZnH5pTH5RvkobnK3Ow9m0RsncaOMAtiAtk,16
92
+ sticker_convert-2.1.15.dist-info/RECORD,,