One of the needs we have daily is to store our photos in a repository, now github in a repository system widely used by the community, in  How to upload images to github from the console , we will teach you to store images in github and The URL is returned to us so we can access it whenever we want. For this we use img2url , we hope that in this way solutions a need that much we have quickly and with the power of github and console.

What is img2url

Img2url is a script made in python by  Haoxun Zhan  and allows uploading images to github repositories from the console, img2url allows you to select the location of the image you want to upload, the account where you want to do it, the chosen repository and finally it returns you A URL with the address where the image you uploaded is located.

How to install img2url

Install img2url is quite simple, we must have installed   Python and Pip so if you do not have it you can do it as follows.

We must execute the following commands:

sudo apt-get install python python-pip

Then we must install the script with the following command

pip install img2url

How to configure img2url

Before using   img2url   we must configure it, so that the script knows where to load the files. Currently, img2url only supports loading images in the public GitHub repository.

The path of the configuration file is:

  • ~/.img2url.yml, default.
  • IMG2URL_CONFIG_PATH, For custom settings.

Example of .img2url.yml:

Token:  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
user:  img2url-testing 
repo:  img2url-testing-travisci

Required fields:

  • tokenPersonal access tokens from your GitHub account. If you do not have one, click on “Generate new token” and select “repo” , then “Save new token”.
  • user: GitHub account.
  • repo: The repository for storing images.

Optional fields:

  • branch: If not defined, use masteras the default branch.
  • path: Path to store the files loaded in your repository. If not defined, use the root of the repository by default.
  • proxies: If defined, use proxy to make API requests instead of connecting directly.
  • message_template_create: Message template to create new file, supported variables: {filename}shatime.
  • message_template_update: Message template for updating existing files, supported variables: {filename}sha,time .
  • commiter_name: User name for the confirmation message.
  • commiter_email: Email for the report message.

How to use img2url

Once we have installed img2url its use is quite simple. We must indicate the path of the image and the script will return the storage path.

$ img2url --help 
    img2url <path>
    img2url (-m | --markdown) <path>

    -m, --markdown


$ 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

$ img2url --markdown image2.png 

Am a tech geek.. Do you wanna know more about me..? My contents will do tell you.

Pin It