项目作者: jonesmartins

项目描述 :
Generate lossy image compressions for fun!
高级语言: Python
项目地址: git://github.com/jonesmartins/pycrusher.git
创建时间: 2017-03-05T22:05:25Z
项目社区:https://github.com/jonesmartins/pycrusher

开源协议:Apache License 2.0

下载


pyCrusher

pyCrusher version
PyPI downloads
Accepted Python versions

Crusher (Wikipedia):

Crushers may be used to reduce the size, or change the form, of waste materials so they can be more easily disposed of or recycled…”

Much like an actual crusher, pyCrusher copies your precious little images and turns them into absolute trash (for fun!)

Install instructions

Pipx

  1. pipx install pycrusher

Uv

  1. uv tool install pycrusher

Pip

  1. pip install pycrusher

Download manually (Linux/MacOS)

  1. git clone https://github.com/jonesmartins/pycrusher
  2. cd pycrusher
  3. python setup.py install

Usage

Type in the command line:

  1. pycrusher <image_file> <flags and parameters>

As default, the program saves your output in a special directory called ‘compressions’ located at path/to/somewhere, so if you use pyCrusher multiple times in path/to/somewhere, you can check your compressed images without mixing it up between your other files.
Every time you save a new file in ‘compressions’, your output file will be saved with your input name followed by the compression settings. You can still use the -o/—output flag and name it however you want.

Default name: compression/<image-name>_i<iterations>e<extra><r><p><c>[colors].<extension>

Options

  1. usage: pycrusher [-h] [-i ITERATIONS] [-e EXTRA] [-c [COLORS ...]] [-o OUTPUT] [-r] [-p] file
  2. positional arguments:
  3. file Name of image to compress
  4. options:
  5. -h, --help show this help message and exit
  6. -i ITERATIONS, --iterations ITERATIONS
  7. Number of compression iterations
  8. -e EXTRA, --extra EXTRA
  9. Number of nested iterations
  10. -c [COLORS ...], --colors [COLORS ...]
  11. Color changes
  12. -o OUTPUT, --output OUTPUT
  13. Name of output file.
  14. -r, --reverse Reverses compression iterations.
  15. -p, --preprocess Adds color enhancement BEFORE compression.

Examples

Original image: crusher.png

crusher


  1. pycrusher crusher.png

Default output filename: compressions/crusher_i50e1.png

compressed_crusher0


  1. pycrusher crusher.png -i 10

Default output filename: compressions/crusher_i10e1.png

compressed_crusher6


  1. pycrusher crusher.png -i 10 -e 5

Default output filename: compressions/crusher_i10e5.png

compressed_crusher1


  1. pycrusher crusher.png -i 20 -c 4

Default output filename: compressions/crusher_i20e1c[4.0].png

compressed_crusher7


  1. pycrusher crusher.png -i 20 -c 4 -r

Default output filename: compressions/crusher_i20e1rc[4.0].png

compressed_crusher5


  1. pycrusher crusher.png -i 20 -c 4 0

Default output filename: compressions/crusher_i20e1c[4.0,0.0].png

compressed_crusher5


  1. pycrusher crusher.png -i 20 -c 4 0 -p

Default output filename: compressions/crusher_i20e1pc[4.0,0.0].png

compressed_crusher1

License

Apache License 2.0