Skip to main content

A handful module for uploading local image and then get the path from specific server, especially good for those writing markdown journals.

Project description

我的图床

需求来源

使用Typora写完的Markdown文章在发布到其他平台(比如公众号、知乎等), 需要考虑将文章内的图片引用转成在线外链。 (虽然可以一张一张手动黏贴到平台,但显然不是程序员的风格,实属太累。) 因此催生了图片转换的需求。

本项目灵感来自于PicGo这款软件,但它是桌面版, 并且在我本地无法运行,故开发了一个python的接口版。

使用说明

使用SM.MS图床

该图床可无需注册使用,即随手上传图片,并获得一个外链。

import myimage
img_path = r'xxxx'
img_path_online = myimage.upload_img(img_path)

使用七牛云

需要配置您键信息,支持两种方式,具体可以参考官方说明:https://portal.qiniu.com/kodo/bucket

1. (推荐)配置settings文件启动

myimage/myimage下新建settings.py文件,填写一下键信息:

DOMAIN = xxx
BUCKET = xxx
AK = xxx
SK = xxx

接着就可以使用以下代码上传图片了:

import myimage
q = myimage.IMG_Qiniuyun()

img_path = r'xxx'
img_path_online = q.upload_img(img_path)
2. 直接通过参数输入启动
import myimage
q = myimage.IMG_Qiniuyun()
q.init_from_params(domain='xx', bucket='xx', ak='xx', sk='xx')

img_path = r'xxx'
img_path_online = q.upload_img(img_path)

TODO

  • [ ] 支持腾讯云、阿里云、Github等其他图床平台
  • [ ] 完善markdown的转换
  • [ ] 其他一些功能欢迎issue

Project details


Download files

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

Files for myimage, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size myimage-0.0.6-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size myimage-0.0.6.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page