Git Product home page Git Product logo

lpic's Introduction

lpic

Linux下的终端图床神器!

用法

用法: lpic [<command>] [<args>]

可用命令:
    help, -h, --help    显示帮助
    del <prefix>        删除Bucket中的文件
    web                 打开Bucket内容管理页面
    put <filename>      上传文件
    use [<cloud>]       切换云服务

省略命令时,上传最新图片。

用Markdown写作时,插入图片比较麻烦。上传图片前要先压缩,然后上传,复制外链。如果用lpic就非常方便了,只需lpic put <filename>即可,会自动压缩、上传、复制外链。

为了更方便,lpic默认上传最新文件。当你想要在Markdown里贴截图时,只需在保存截图之后到截图所在目录运行lpic,然后粘贴外链到你的文章里即可。

另外,lpic del <prefix>能删除Bucket中的文件。lpic web能召唤默认浏览器打开Bucket内容管理页面,方便手动管理。

支持阿里云、腾讯云和七牛云。

安装

下载该项目:

$ git clone https://github.com/jlice/lpic.git

安装依赖:

$ pip3 install -r lpic/requirements.txt

lpic.example.yml复制一份为lpic.yml,此为配置文件,修改之:

$ cd lpic/src
$ cp lpic.example.yml lpic.yml
$ vim lpic.yml

为了能在终端使用lpic命令直接调用,可以创建一个软链接:

$ chmod +x main.py
$ sudo ln -s $PWD/main.py /usr/local/bin/lpic

更多细节详见Wiki

变更日志

2019.05.25

  1. 增加支持阿里云
  2. 允许限制图片大小
  3. 支持多种重命名格式
  4. 允许自定义输出形式
  5. 支持透明区域填色

2018.11.09

  1. 增加Windows支持
  2. 修复了转换带Alpha通道PNG的BUG
  3. 优化配置文件结构(兼容之前的格式)

lpic's People

Contributors

straicat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lpic's Issues

PNG带alpha通道时,无法转为JPEG

若PNG带alpha通道,尝试转为JPEG会出现以下错误:

Traceback (most recent call last):
  File "/home/wjmr/.pyenv/versions/3.5.4/lib/python3.5/site-packages/PIL/JpegImagePlugin.py", line 620, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/lpic", line 22, in <module>
    _main()
  File "/usr/local/bin/lpic", line 16, in _main
    TencentLPic().main()
  File "/home/wjmr/.local/lpic/lpic/base.py", line 76, in main
    self._upload_default()
  File "/home/wjmr/.local/lpic/lpic/base.py", line 65, in _upload_default
    new_file = self.preprocess(files[0])
  File "/home/wjmr/.local/lpic/lpic/base.py", line 47, in preprocess
    im.save(new_file, format='JPEG', optimize=True, progressive=True)
  File "/home/wjmr/.pyenv/versions/3.5.4/lib/python3.5/site-packages/PIL/Image.py", line 1935, in save
    save_handler(self, fp, filename)
  File "/home/wjmr/.pyenv/versions/3.5.4/lib/python3.5/site-packages/PIL/JpegImagePlugin.py", line 622, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
OSError: cannot write mode RGBA as JPEG

一些打算的新功能

  • 图片自动缩放功能

有时会传一些大图作为博客的装饰图片,有的图片过大,浪费流量,拖慢速度。
所以,增加一个图片自动缩放的功能。设置图片最大尺寸,超出尺寸就自动缩放。

  • 支持del指定的文件

腾讯云网页版控制台有时实在太慢了。当前del只能删除最近的一个,应该像put那样可以删除指定的。

由于进行了图片重命名,所以del时必须指定名字。

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.