Skip to main content

介绍

在上传图片的时候, 经常会用到图床功能.

此工具聚合了一些常用的图床, 以便于快速使用. 演示站点

注意: 因免费图床的稳定性无法保证, 因此请勿用其保存重要文件

说明

因为使用各种免费服务, 稳定性无法保证

若各位在使用过程中碰到问题, 欢迎下列任选一种方式补充:

  1. 提交isuse说明问题
  2. 将问题写到DepotType的对应文档上

如果你有其他优秀的图床推荐, 欢迎提交isusePR

当前支持的所有图床, 可查看文件DepotType

使用

安装:

pip install image-depot

指定单个图床进行上传

from image_depot import image_depot, DepotType

# 选择图床对象
d = image_depot(DepotType.CatBox)
# 上传图片. 二进制内容
image_content = ''
image_url = d.upload(image_content)
if not image_url:  # 图片上传失败, 获取失败原因
    print(d.error())
# 上传图片, 使用本地文件路径
file_path = ''
image_url = d.upload_file(file_path)

多个图床依次尝试上传:

from image_depot import upload, upload_file, DepotType

type_list = [DepotType.SmMs]
# 上传图片. 二进制内容. 若所有图床都上传失败, 则返回空字符串以及所有错误信息
image_content = ''
url, err = upload(image_content, type_list=type_list)
# 依次尝试所有图床, 返回第一个成功的. 
file_path = ''
upload_file(file_path, type_list=type_list)

图床配置:

from image_depot import image_depot, DepotType, upload, upload_file, DepotConfig, set_global_config

# 部分图床需要添加配置才能使用
# 全局配置
config = DepotConfig()
config.sm_ms.token = ''
set_global_config(config)

# 可以为每次上传使用不同的配置信息
# 此配置优先级高于 global_config
d = image_depot(DepotType.CatBox)
d.set_config(config)
upload('', config=config)
upload_file('', config=config)

Release files for image-depot 0.12.3

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

Source distribution (sdist)

Source distribution for image-depot 0.12.3
File Size Uploaded
image_depot-0.12.3.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for image-depot 0.12.3
File Interpreter ABI Platform
image_depot-0.12.3-py3-none-any.whl Python 3 none any Details

Total release size: 39.2 kB

Release files / image_depot-0.12.3.tar.gz

Download URL image_depot-0.12.3.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dddef32153e04b1f9c6e9c9f6c5a3359b09ef8a224871ddf64cb511a51929b0f
BLAKE2b-256 checksum
How to use checksums
c24a2fb47e8dea8e6439bff96dd759956319945cd927c1d79b191530bd6e4f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / image_depot-0.12.3-py3-none-any.whl

Download URL image_depot-0.12.3-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cdbf73fd58e55de5e68228d5d3d28c9acb205616ad8b0734d3e2d4c4d038804
BLAKE2b-256 checksum
How to use checksums
e71a184c76382828bc9be7d9a13d6a128d512295ea67f964a13666dbdc9e711f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.12.3 This release

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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