loadimg
A python package for loading and converting images
How to use
Installation
pip install loadimg
Usage
from loadimg import load_img
load_img(any_img_type_here,output_type="pil",input_type="auto")
Supported types
-
Currently supported input types :
- numpy
- pillow
- str(both path and url)
- base64
- auto
-
Currently supported output types :
- numpy
- pillow
- str
- base64
The base64 is now compatible with most APIs, now supporting Hugging Face, OpenAI and FAL
from loadimg import load_img
from huggingface_hub import InferenceClient
# or load a local image
my_b64_img = load_img("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg", output_type="base64" )
client = InferenceClient(api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": my_b64_img # base64 allows using images without uploading them to the web
}
}
]
}
]
stream = client.chat.completions.create(
model="meta-llama/Llama-3.2-11B-Vision-Instruct",
messages=messages,
max_tokens=500,
stream=True
)
for chunk in stream:
print(chunk.choices[0].delta.content, end="")
Contributions
- - thanks to @KingNish24 for improving base64 support and adding the
input_typeparameter and adding theurloutput type - thanks to @Saptarshi-Bandopadhyay for supporting base64 and improving the docstrings
- thanks to @Abbhiishek for improving image naming
- thanks to @BouajilaHamza for adding multiple image support
Metadata
Release files for loadimg 0.5.0
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 | Actions |
|---|---|---|---|---|
| loadimg-0.5.0.tar.gz | 15.0 kB | Without provenance | Details for loadimg-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loadimg-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for loadimg-0.5.0-py3-none-any.whl |
Total release size: 26.3 kB
Release files / loadimg-0.5.0.tar.gz
| Download URL | loadimg-0.5.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d82ff7c428ca8fd49e6548ffa15898c89b9631cf430d8ec2bb89f868a50bcd14
|
|
BLAKE2b-256 checksum How to use checksums |
44b6b3daf7d1aab39153364da4d31424bdf43a927c9e6422b32fe24503653095
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / loadimg-0.5.0-py3-none-any.whl
| Download URL | loadimg-0.5.0-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceccde9145baa8f307dfa7b2549ffb0da70cf60eda9ca4323037865d175347f7
|
|
BLAKE2b-256 checksum How to use checksums |
8b907178f04fec337ab8450183b67518858b3397d7ab50c71d79761982ad7421
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for loadimg 0.5.0
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.