项目作者: nitinkamra1992

项目描述 :
Image Compression Tool
高级语言: Python
项目地址: git://github.com/nitinkamra1992/CompressPics.git
创建时间: 2018-06-05T10:12:45Z
项目社区:https://github.com/nitinkamra1992/CompressPics

开源协议:

下载


CompressPics

This is an image compression tool built on top of imagemagick convert tool. It adds support for compressing all images in a directory (recursively), along with a minimum size constraint.

Compatibility

The tool has been tested on Ubuntu and Python3.5+.

Dependencies

The tool requires python3.5+. While the imagemagick package might be pre-installed on Ubuntu, install it if needed:

  1. sudo apt update
  2. sudo apt install imagemagick

Also, install dependencies:

  1. pip install filetype

Usage

The tool can be run as a Python script, e.g.:

  1. python3 compress_pics.py -d <data_dir> -o <out_dir> -m 1000000 -rec -v -resize 50% -quality 50%

It supports all arguments for the imagemagick convert tool, and additionally the following arguments:

  1. -d, --data: Input file/directory
  2. -o, --out: Output file/directory. Default: Same as input file/directory.
  3. -m, --minsize: Minimum size of a file to compress (in bytes). Type = int, Default = 0.
  4. -rec, --recursive: Recursively process subdirectories if input is a directory.
  5. -v, --verbose: Increase verbosity.

Note that the tool only processes image files. All other unsupported files are copied over directly. Any file smaller than --minsize is copied over directly. If -rec is not specified, all subdirectories are copied directly to the output directory.