Skip to main content

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"
}

Release files for image2url 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for image2url 0.1.0
File Size Uploaded
image2url-0.1.0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for image2url 0.1.0
File Interpreter ABI Platform
image2url-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size:22.4 kB

Release files / image2url-0.1.0.tar.gz

Download URL image2url-0.1.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5d40a0f5c3c3598c3f141912ae65469c2116a62baff95c9fb2d7864dd11608bd
BLAKE2b-256 checksum
How to use checksums
8483bbfb3e2ad50e1a212fe98b319e95199d79f782383dd7bdc4bb9f5bc15075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / image2url-0.1.0-py3-none-any.whl

Download URL image2url-0.1.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1056a0602b23ddb4a99452e9246cd29d6915006d90450b6005d51f44895bd3b
BLAKE2b-256 checksum
How to use checksums
0dae72d916b6c223b8e841180e151ce9fad1d6bdea3e98f87ed89bab539e3fc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page