This project has been archived by its maintainers, and is no longer receiving any updates.
PY-SIC
English | 简体中文
PY-SIC stands for "a simple image converter for Python". It could be seen as a simple wrapper of the popular Python imaging library Pillow, but contains a patch for better GIF conversion quality, thanks to the workaround provided by @egocarib. The idea of maintaining this repository comes from the process of refactoring the scripts in another repository of mine named Weibo Emoji. The primary purpose is automation, as I found it time-consuming to convert images and keep the original file structure manually. In summary, PY-SIC can mainly help you with:
- Conversion tasks with an image or multiple images for many popular image formats (TODO: currently supports GIF and PNG in the alpha release)
- Customisation including but not limited to controlling the alpha threshold for converting images to GIF ones, showing the progress bar, keeping the file structure of the input directory, and specifying the output directory.
Please note that the code is licensed under the GPL-3.0 License.
❗ ATTENTION
May I have your attention pls? 🔥
-
By 17 October 2021, everything looks good with PyCharm 2021.2.2 + Python 3.10.0. You could definitely use Visual Studio Code, but you might need to adjust the importing behaviour in some scripts to make them run correctly.
-
PY-SIC should support Python 3.6+, and relies on the packages listed below. To build the package yourself, please refer to the package requirements for this project.
Name Version Pillow ≥ 8.4.0 tqdm ≥ 4.62.2
📜 Docs
TODO: This part will have significant changes since PY-SIC is in its super alpha release.
Installation
pip install py-sic # Use pip3 if required.
Sample Usage
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)
Hope you would find it useful! 💖
Metadata
Release files for py-sic 0.3.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| py-sic-0.3.0a1.tar.gz | 20.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_sic-0.3.0a1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.0 kB
Release files / py-sic-0.3.0a1.tar.gz
| Download URL | py-sic-0.3.0a1.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3474739037a94c5da221db6dc34c8c73314d32819be90afb4e40a111e32ead59
|
|
BLAKE2b-256 checksum How to use checksums |
dec9090ff67747fc59e866fb105bce764ce4f5ad587db2288dbabc7ca86c39dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / py_sic-0.3.0a1-py3-none-any.whl
| Download URL | py_sic-0.3.0a1-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efa5690c91e52497db4cfc7c656a68c4c40d8490696ccde1cc9f6ad5854cdfe2
|
|
BLAKE2b-256 checksum How to use checksums |
21254ef6f9920018060aba784c51f9e89a18bd4e3483a7e0a8d2db7c4b32724a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for py-sic 0.3.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.