GithubHelp home page GithubHelp logo

img2url's Introduction

img2url

Introduction

img2url transforms a local image file to an url by uploading the file to remote. img2url helps you write portable document, especially markdown file, in such a way you don't need to worry about where to place the static resource like images!

Supported remotes:

  • GitHub Repository (by default).
  • Qiqiu Object Storage.

Install

img2url is a Python project, use pip to install:

pip install img2url

Command-Line Interface

And the CLI is pretty simple:

$ img2url --help 
Usage:
    img2url [--no-clipboard] <path>
    img2url [--no-clipboard] (-m | --markdown) <path>

Options:
    --no-clipboard  Prevent copying result to clipboard.
    -m, --markdown  Return Markdown format of image url.

Example:

$ ls -al
total 56
drwxr-xr-x  4 haoxun  staff    136 Aug 13 21:26 .
drwxr-xr-x  8 haoxun  staff    272 Aug 13 21:23 ..
-rw-r--r--@ 1 haoxun  staff  23975 Aug 13 21:26 image1.png
-rw-r--r--@ 1 haoxun  staff   3727 Aug 13 21:26 image2.png

$ img2url image1.png 
https://cdn.rawgit.com/huntzhan/img2url-repo/master/image1.png

$ img2url --markdown image2.png 
![image2.png](https://cdn.rawgit.com/huntzhan/img2url-repo/master/image2.png)

Configuration

User should configure img2url before actually using it, so that img2url knows where to upload the files.

Path of configuration file:

  • ~/.img2url.yml, by default.
  • IMG2URL_CONFIG_PATH, customized path.

Currently, img2url supports following remotes, remote is specified by setting remote key in configuration file. If remote is not defined, github is selected as remote by default.

Remote Field Setting
GitHub Repository remote: github
Qiqiu Object Storage remote: qiniu

Configuration of GitHub Repository

Example of .img2url.yml:

remote: github

githu_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
githu_user: img2url-testing
githu_repo: img2url-testing-travisci

proxies:
  https: socks5://127.0.0.1:1080

Supported fields:

field required default
github_token yes -
github_user yes -
github_repo yes -
github_branch no "master"
github_path no ""
github_commiter_name no "huntzhan"
github_commiter_email no "[email protected]"
message_template_create no "{filename} created by img2url at {time}."
message_template_update no "{filename} updated by img2url at {time}."
proxies no None

Meaning of fields:

  • github_token: Personal access tokens of your GitHub account. If you don't have one, click "Generate new token" and select the "repo" scope, then record the generated token.

  • github_user: Account of GitHub.

  • github_repo: The repository to store images.

  • github_branch: If not defined, use master as the default branch.

  • github_path: Path to store the uploaded files in your repository. If not defined, use the root of repository by default.

  • proxies: If defined, use proxy to make API requests instead of connecting directly.

  • message_template_create: Message template for creating new file, supported variables: {filename}, sha, time.

  • message_template_update: Message template for updating existed file, supported variables: {filename}, sha, time.

  • github_commiter_name: Username for commit message.

  • github_commiter_email: Email for commit message.

Configuration of Qiqiu Object Storage

Example of .img2url.yml:

remote: qiniu

qiniu_access_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
qiniu_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
qiniu_bucket: img2url
qiniu_base_url: xxxxxxxxx.bkt.clouddn.com

Supported fields:

field required default
qiniu_access_key yes -
qiniu_secret_key yes -
qiniu_bucket yes -
qiniu_base_url yes -

Meaning of fields:

  • qiniu_access_key, qiniu_secret_key: Access/Secret Key
  • qiniu_bucket: the name of Qiniu object storage space.
  • qiniu_base_url: domain of Qiniu object storage space.

img2url's People

Contributors

huntzhan avatar xterat avatar

Stargazers

 avatar  avatar Bright Li avatar  avatar  avatar im-oss avatar Niko Lee avatar 爱尔兰雷 avatar  avatar  avatar  avatar Fat Bob Go avatar  avatar 0xb2 avatar  avatar  avatar panbin avatar 孙华岩 avatar 白大哥 avatar Katsura avatar Mashiro avatar Na Meng avatar  avatar Rowen avatar CHAOJIE LYU avatar xunsyn avatar lemos avatar nicolasalarconrapela avatar xwqiang avatar xyzdh avatar Jaeger avatar  avatar Trang avatar  avatar Jerzerak avatar BYaka avatar stormluke avatar lux avatar Xuezhi Zhang avatar 徐磊 avatar 李中明 avatar flyfire avatar Ahmed avatar Jeremy Bae avatar Illarion avatar  avatar Sergey Miletskiy avatar Ricky avatar Matt H avatar  avatar Martín Gaitán avatar Filipp Frizzy avatar  avatar Alejandro avatar Airing avatar 爱可可-爱生活 avatar James Campbell avatar Zehao Huang avatar Peter Brinck avatar SkyKai avatar Hongliang Liu avatar  avatar Chion avatar guozi_1989 avatar  avatar Kai Chen avatar Vien_Dave avatar yoCruzer avatar Nick avatar  avatar Yiwen Lu avatar  avatar RoyLi avatar 5aaee9 avatar  avatar  avatar domainbank avatar 塟愛鎵镞の風仯 avatar Tong Wu avatar Leonn avatar Norcy avatar Jim Ma avatar

Watchers

 avatar James Cloos avatar  avatar Hao Ge avatar newdee avatar Sylar avatar  avatar Acherzyc avatar

img2url's Issues

配置文件 Example

Configuration of GitHub Repository

Example of .img2url.yml:

remote: github

githu_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
githu_user: img2url-testing
githu_repo: img2url-testing-travisci

proxies:
  https: socks5://127.0.0.1:1080

这里应该是:

remote: github

github_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
github_user: img2url-testing
github_repo: img2url-testing-travisci

proxies:
  https: socks5://127.0.0.1:1080

not able to run img2url

steps to reproduce:

  • install img2url by pip.
  Found existing installation: PySocks 1.6.7
    Uninstalling PySocks-1.6.7:
      Successfully uninstalled PySocks-1.6.7
  Found existing installation: img2url 0.2.0
    Uninstalling img2url-0.2.0:
      Successfully uninstalled img2url-0.2.0
Successfully installed PyYAML-3.12 certifi-2017.11.5 chardet-3.0.4 docopt-0.6.2 future-0.16.0 idna-2.6 img2url-0.2.0 pyperclip-1.6.0 pysocks-1.6.7 qiniu-7.1.9 requests-2.18.4 urllib3-1.22
  • run it
 Dropbox  Screenshots  $  img2url Screenshot\ 2017-08-27\ 16.00.31.png 
Traceback (most recent call last):
  File "/usr/local/bin/img2url", line 11, in <module>
    sys.exit(entry_point())
  File "/usr/local/lib/python2.7/site-packages/img2url/main.py", line 99, in entry_point
    path, fields, RemoteConfig, RemoteOperation,
  File "/usr/local/lib/python2.7/site-packages/img2url/main.py", line 61, in upload_file
    exists_files = operator.list_remote()
  File "/usr/local/lib/python2.7/site-packages/img2url/remotes/github.py", line 254, in list_remote
    return list_repo(self.config.fields)
  File "/usr/local/lib/python2.7/site-packages/img2url/remotes/github.py", line 232, in list_repo
    assert_status_code(rep, 200)
  File "/usr/local/lib/python2.7/site-packages/img2url/remotes/github.py", line 118, in assert_status_code
    raise RuntimeError('FATAL on making request')
RuntimeError: FATAL on making request

返回图片链接问题

经测试,现在图片链接前缀为https://raw.githubusercontent.com/而不是https://cdn.rawgit.com/

img2url package level issue

新年好。我在尝试使用IDE运行 img2url 代码。因为包的引用问题发生错误。请问一下应该怎样放置代码才能正确运行?

How about a web interface?

Like some web editors always do , a handy way to get the urls of my screenshot pictures or other images.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.