loadimg - Image loading utility
raw JSON → 0.5.0 verified Fri May 01 auth: no python
loadimg is a Python package for loading images from various sources (local files, URLs, base64 strings) and converting to multiple output types (PIL, numpy, base64, ASCII art, URL). Current version 0.5.0, released 2025-03-18. Active development.
pip install loadimg Common errors
error ModuleNotFoundError: No module named 'loadimg.utils' ↓
cause Installation of loadimg failed or version <0.4.0 where utils module didn't exist.
fix
Ensure loadimg >=0.4.0 is installed:
pip install --upgrade loadimg error AttributeError: module 'loadimg' has no attribute 'load_img' ↓
cause Using old import `from loadimg import load_img` with loadimg >=0.4.0.
fix
Change to
from loadimg.utils import load_img error ValueError: Unsupported output type: 'pil' ↓
cause Pillow is not installed. PIL output requires the Pillow package.
fix
Install Pillow:
pip install pillow error requests.exceptions.MissingSchema: Invalid URL 'file.jpg': No schema supplied. ↓
cause Passing a local file path without prefix; load_img expects a URL or base64.
fix
Use an absolute path or prefix with 'file://', or use the
path input_type (not yet supported). Alternatively, pass as base64. Warnings
breaking In v0.4.0, import paths changed from `loadimg` to `loadimg.utils`. Code using `from loadimg import load_img` will break. ↓
fix Use `from loadimg.utils import load_img`.
breaking In v0.3.0, the `output_type` parameter was introduced. Old code without `output_type` may return bytes instead of PIL Image. ↓
fix Explicitly specify `output_type='pil'` to get PIL Image.
gotcha The `load_img` function does not automatically detect input type; you must specify `input_type` for non-URL sources (e.g., base64). ↓
fix Use `input_type='base64'` when passing a base64 string.
deprecated The `load_imgs` function (plural) was added in v0.5.0 but may change signature in future releases. ↓
fix Check release notes for updates.
Imports
- load_img wrong
from loadimg import load_imgcorrectfrom loadimg.utils import load_img - load_imgs wrong
from loadimg import load_imgscorrectfrom loadimg.utils import load_imgs
Quickstart
from loadimg.utils import load_img
img = load_img('https://example.com/image.jpg', output_type='pil')
print(type(img))