Skip to main content

loadimg

Downloads

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_type parameter and adding the url output 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loadimg-0.5.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loadimg-0.5.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file loadimg-0.5.0.tar.gz.

File metadata

  • Download URL: loadimg-0.5.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for loadimg-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d82ff7c428ca8fd49e6548ffa15898c89b9631cf430d8ec2bb89f868a50bcd14
MD5 6c2c14e763fbec2af8831fc65775c6f3
BLAKE2b-256 44b6b3daf7d1aab39153364da4d31424bdf43a927c9e6422b32fe24503653095

See more details on using hashes here.

File details

Details for the file loadimg-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: loadimg-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for loadimg-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ceccde9145baa8f307dfa7b2549ffb0da70cf60eda9ca4323037865d175347f7
MD5 696c729e0719e39e3d8ccc026bad45dc
BLAKE2b-256 8b907178f04fec337ab8450183b67518858b3397d7ab50c71d79761982ad7421

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.3

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page