Skip to content

Mopip77/screenshot-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot Handler

It provides a set of image-handling tools to handle screenshot from clipboard.

Avaliable handlers

  • Upload to image host
  • OCR
  • Base64
  • Copy to path
  • Image search (TODO)
  • Add invisible watermark to image (TODO)

Install

a. Install with go

go install github.com/Mopip77/screenshot-handler

b. Or you can just download bin from Release page.


Then set a short alias for screenshot-handler

echo "alias sch=screenshot-handler" >> ~/.bashrc

Usage

See sch --help for more information, the default config file ~/.schrc.yaml will be generated when first run.

First of all, take a screenshot then copy it to clipboard.

Upload to image host

  1. Set an auth token for image host, and choose which to use in configuration.

    # upload to image host settings
    upload:
    use:  # support multiple host
      - smms
      - github
    smms_token:
    github:
        username: # github username
        repo:     # image host repo
        token:    # github token with repo permission

    You can generate token from: SMMS, Github

    Reminder: the repo scope permission is required when creating Github token.

  2. Run sch upload or sch u to upload the screenshot to image host.

    $ sch u
    upload image to github success, url: https://cdn.jsdelivr.net/gh/Mopip77/image-host/20220405/120401.png
    
    Markdown: ![screenshot.png](https://cdn.jsdelivr.net/gh/Mopip77/image-host/20220405/120401.png)
    BBCode  : [IMG]https://cdn.jsdelivr.net/gh/Mopip77/image-host/20220405/120401.png[/IMG]
    HTML    : <img src="https://cdn.jsdelivr.net/gh/Mopip77/image-host/20220405/120401.png" alt="screenshot.png">
    
    markdown template saved to clipboard.

    The screenshot in clipboard will be uploaded to image host. Then the markdown tmeplate will be copied to clipboard.

    Tips: github url will be delivered via js delivr CDN by default. You can use --js-delivr=false to disable.

    For more args usage, check sch upload --help.

OCR

  1. Set token in ~/.schrc.yaml:

    # ocr settings
    ocr:
    use: # tencent
    tencent:
        secret_id:
        secret_key:

    Only tencent ocr service avaliable now. Get Tencent OCR Token

  2. Then run sch o

Others

Check other command usages by sch --help.

Screenshot Source

1. Clipboard (default)

For convenience, sch will get screenshot from clipboard by default.

2. Screenshot Folder

But you can also specify the screenshot folder in ~/.schrc.yaml:

# default screenshot folder
screenshot_folder: <change-to-your-screenshot-folder>

Then run with -d or --dir global flag to get newest screenshot in the folder.

sch -d <command>

3. Specific Filepath

use --file option to specify the screenshot filepath.

sch --file=~/a.png <command>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages