
ภาษาอังกฤษ | 简体中文
PY-SIC ย่อมาจาก "ตัวแปลงภาพที่เรียบง่ายสำหรับ Python" มันอาจถูกมองว่าเป็นหมอนห่อหุ้ม Python Imaging ยอดนิยม แต่มีแพตช์เพื่อคุณภาพการแปลง GIF ที่ดีขึ้นด้วยการแก้ปัญหาที่ได้รับจาก @egocarib ความคิดในการบำรุงรักษาที่เก็บนี้มาจากกระบวนการของการปรับโครงสร้างสคริปต์ในที่เก็บอื่นของฉันชื่อ Weibo Emoji วัตถุประสงค์หลักคือระบบอัตโนมัติเนื่องจากฉันพบว่าใช้เวลานานในการแปลงภาพและรักษาโครงสร้างไฟล์ต้นฉบับด้วยตนเอง โดยสรุป PY-SIC ส่วนใหญ่สามารถช่วยคุณได้:
โปรดทราบว่ารหัสได้รับใบอนุญาตภายใต้ใบอนุญาต GPL-3.0
ฉันขอความสนใจของคุณได้ไหม
เมื่อวันที่ 17 ตุลาคม 2564 ทุกอย่างดูดีด้วย Pycharm 2021.2.2 + Python 3.10.0 คุณสามารถใช้รหัส Visual Studio ได้อย่างแน่นอน แต่คุณอาจต้องปรับพฤติกรรมการนำเข้าในสคริปต์เพื่อให้ทำงานได้อย่างถูกต้อง
PY-SIC ควรรองรับ Python 3.6+ และขึ้นอยู่กับแพ็คเกจที่ระบุไว้ด้านล่าง ในการสร้างแพ็คเกจด้วยตัวเองโปรดดูข้อกำหนดของแพ็คเกจสำหรับโครงการนี้
| ชื่อ | รุ่น |
|---|---|
| หมอน | ≥ 8.4.0 |
| TQDM | ≥ 4.62.2 |
TODO: ส่วนนี้จะมีการเปลี่ยนแปลงที่สำคัญเนื่องจาก PY-SIC อยู่ในการเปิดตัว 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 )หวังว่าคุณจะพบว่ามีประโยชน์! -