How to upload images to github from the console

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

What is img2url

img2url is a script made in python by Haoxun zhan and that 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 a URL with the address where the image you have uploaded is located.

How to install img2url

Installing img2url is quite simple, we must have installed  python y Pip so if you don't have it you can do it in the following way.

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 uploading images to the public GitHub repository.

The configuration file path is:

  • ~/.img2url.yml, default.
  • IMG2URL_CONFIG_PATH, for custom configuration.

Example of .img2url.yml:

We token:  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
user:  img2url-testing 
repos:  img2url-testing-travisci 

Required fields:

  • token: Personal access tokens from your GitHub account. If you don't 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 uploaded files in your repository. If not defined, use the repository root by default.
  • proxies: If defined, use proxy to make API requests instead of connecting directly.
  • message_template_create: Template message to create new file, variables supported: {filename},sha, time.
  • 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 img2url installed, its use is quite simple. We must indicate the path of the image and the script will return the storage path.

img2url

img2url

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

Options:
    -m, --markdown

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)

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Oscar said

    And does that have any use for someone who uses Linux? I've been using Linux for a while, but I'm not familiar with GitHub.

  2.   Guille said

    Interesting, but I don't see important information: Github capacity, the photos would be visible to everyone, license the photos?

  3.   Guille said

    Interesting, but I don't see any information that could be important: Github capacity, the photos would be in view of everyone, license the photos?

  4.   Ruben espinoza said

    Diossss but how is it going to be useless? if that serves to place as cover, or description for the repository in github, for example main view of a web application among others ...