/webp-converter

Converter PNG/JPG to Webp and scan all changes

Primary LanguagePythonApache License 2.0Apache-2.0

Webp Converter and Analytics

An powerful webp batch converter and differ analytics tool.

You can use this tool to converter batch images(png/jpg) to webp and output size changes.

Purpose

  1. Convert batch images from PNG/JPG format to Webp format
  2. WILL NOT convert images if its webp one is larger than origin one automatically(the origin one will be copied to [output-directory]/origin/ directory)
  3. WILL NOT convert images if it is failed to convert to webp one automatically(the origin image of failed one will be copied to [output-directory]/failed directory)
  4. You can ignore all images which has transparency pixel if you want with --ignore-transparency-image config(the origin image of has-transparency-image will be copied to /webp-converted/transparency directory)
  5. Output convert result, like how much size reduces, how many files skip convert, etc...
  6. You can replace the images with converted-webp image automatically if you want with replace: true config

Install

brew install webp
pip install webp-converter

Use

Example

If you just want to convert all images on the current files when it can be smaller after converted and replace the origin one:

webpc --r

If you just want to convert all images on the current folder and with quality-ratio to 70 and output to ~/Downloads/test-converted when it can be smaller after converted:

webpc -q=70 -o=~/Downloads/test-converted/

If you just want to convert all images on the current folder and with clean the webp-converted folder if it exist and with quality-ratio to 95 and output to ./webp-converted and ignore images when it has transparency on it when it can be smaller after converted:

webpc --c --ignore-transparency-image -q=95

If you want to convert ignore filename contain the sepcial word, you can use --ignore-filename-match, the following demo is skip convert all files which name contains '.9':

webpc --r --ignore-filename-match='.9'

If you want to convert all images on ~/Downloads/img/test folder and output converted result to ~/Downloads/test-converted folder and only converted origin images when it isn't has same name .webp file on ~/Downloads/test-converted folder(just not with --c argument) when it can be smaller after converted:

webpc -o=~/Downloads/test-converted/ ~/Downloads/img/test

My Terminal Config

If you want to adapter the same theme like screenshot above, it's very easy:

  • Firstly, please use powerlevel9k theme(Install the Powerlevel9k Theme and Powerline Fonts as the powerlevel9k repo readme doc said).
  • Secondly, please config the iTerm2-Neutron color scheme.
  • Thirdly, please config your shell(If you are using zsh, just add following code to the ~/.zshrc file):
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time)
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S}"
POWERLEVEL9K_NODE_VERSION_BACKGROUND='022'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2

License

Copyright 2017, JacksGong(https://jacksgong.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.