Tiny Python client for uploading images to image2url and getting a permanent URL.
Project description
image2url (PyPI)
轻量级 Python SDK + CLI,用来把本地图片上传到 image2url API,返回一个可长期访问的公开 URL。默认指向 https://www.image2url.com/api/upload,也可通过环境变量切换到你自己的部署。
功能
- 上传本地图片并返回永久 URL
- 内置 2MB 体积校验(与默认 API 对齐,可自定义)
- 自定义上传地址、超时时间与文件名
- CLI 一键上传,或在 Python 代码中调用
安装
# 发布后
pip install image2url
# 本地开发/调试
pip install -e .[dev]
Python 快速开始
from image2url import Image2URLClient, upload_image
# 方式 1:直接用便捷函数
result = upload_image("avatar.png")
print(result.url)
# 方式 2:自定义客户端
client = Image2URLClient(
endpoint="https://www.image2url.com/api/upload",
timeout=15,
max_size_mb=2,
)
result = client.upload_image("avatar.png", filename="profile.png")
print(result.url)
CLI 用法
# 最简单用法
image2url ./avatar.png
# 自定义地址、超时并输出完整 JSON
IMAGE2URL_ENDPOINT=https://your-domain.com/api/upload \
image2url ./avatar.png --timeout 30 --json
配置
IMAGE2URL_ENDPOINT:自定义上传地址(默认https://www.image2url.com/api/upload)IMAGE2URL_TIMEOUT:请求超时秒数(默认 15)max_size_mb:初始化客户端时自定义体积限制(默认 2MB)
本地开发
pip install -e .[dev]
python -m pytest
返回示例
{
"success": true,
"url": "https://www.image2url.com/images/1733090000-uuid.png",
"filename": "images/1733090000-uuid.png",
"originalName": "avatar.png",
"size": 102400,
"type": "image/png",
"uploadedAt": "2024-12-02T00:00:00.000Z"
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
image2url-0.1.0.tar.gz
(16.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image2url-0.1.0.tar.gz.
File metadata
- Download URL: image2url-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d40a0f5c3c3598c3f141912ae65469c2116a62baff95c9fb2d7864dd11608bd
|
|
| MD5 |
fa6c3131b39d7c21edc33a0b5ae9f698
|
|
| BLAKE2b-256 |
8483bbfb3e2ad50e1a212fe98b319e95199d79f782383dd7bdc4bb9f5bc15075
|
File details
Details for the file image2url-0.1.0-py3-none-any.whl.
File metadata
- Download URL: image2url-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1056a0602b23ddb4a99452e9246cd29d6915006d90450b6005d51f44895bd3b
|
|
| MD5 |
017ef903ddbc4569758152bb7e74b04f
|
|
| BLAKE2b-256 |
0dae72d916b6c223b8e841180e151ce9fad1d6bdea3e98f87ed89bab539e3fc8
|