
Bahasa Inggris | 简体中文
Py-sic adalah singkatan dari "Konverter Gambar Sederhana untuk Python". Ini dapat dilihat sebagai pembungkus sederhana dari bantal perpustakaan Python Imaging yang populer, tetapi berisi tambalan untuk kualitas konversi gif yang lebih baik, berkat solusi yang disediakan oleh @egocarib. Gagasan mempertahankan repositori ini berasal dari proses refactoring skrip di gudang saya yang lain bernama Weibo Emoji. Tujuan utamanya adalah otomatisasi, karena saya menemukan itu memakan waktu untuk mengonversi gambar dan menjaga struktur file asli secara manual. Singkatnya, Py-Sic terutama dapat membantu Anda dengan:
Harap dicatat bahwa kode tersebut dilisensikan di bawah lisensi GPL-3.0.
Apa boleh saya minta perhatian Anda?
Pada 17 Oktober 2021, semuanya terlihat bagus dengan Pycharm 2021.2.2 + Python 3.10.0. Anda pasti dapat menggunakan kode Visual Studio, tetapi Anda mungkin perlu menyesuaikan perilaku impor dalam beberapa skrip untuk membuatnya berjalan dengan benar.
Py-sic harus mendukung Python 3.6+, dan bergantung pada paket yang tercantum di bawah ini. Untuk membangun paket sendiri, silakan merujuk ke persyaratan paket untuk proyek ini.
| Nama | Versi |
|---|---|
| Bantal | ≥ 8.4.0 |
| TQDM | ≥ 4.62.2 |
TODO: Bagian ini akan memiliki perubahan signifikan karena Py-SIC dalam rilis super alpha.
pip install py-sic # Use pip3 if required. from pysic . engine import SIC
from pysic . errors import EmptyInputError
from pysic . pillow_gif_patch import ALPHA_THRESHOLD
FAIL = "Fail:"
sic = SIC (
has_pbar = True , # A flag indicating whether to show the progress bar or not.
input_path = "your/path/to/input" # The path to an input image or the directory for locating the input image(s).
)
try :
sic . convert (
alpha_threshold = ALPHA_THRESHOLD , # The threshold for the alpha channel.
has_init_output = False , # A flag indicating if the output directory should be cleaned up first.
has_input_structure = True , # A flag indicating if the file structure of the input directory should be kept.
output_dir = "your/path/to/output" # The output directory for the converted image(s).
to_fmt = to_fmt # The target image format for conversion.
)
except EmptyInputError as empty_input :
print ( FAIL , empty_input )
except FileExistsError as file_exists :
print ( FAIL , file_exists )
except FileNotFoundError as input_not_found :
print ( FAIL , input_not_found )
except ValueError as value :
print ( FAIL , value )Semoga Anda merasa berguna! ?