victordomingos / optimize-images

A command-line interface (CLI) utility written in pure Python to help you reduce the file size of images.
https://no-title.victordomingos.com/projects/optimize-images
MIT License
269 stars 49 forks source link

Added the ability to import this program into other Python programs #32

Closed truethari closed 3 years ago

truethari commented 3 years ago

Usage

options

src_path, watch_dir, recursive, quality, remove_transparency, reduce_colors, max_colors, max_w, max_h, keep_exif, convert_all, conv_big, force_del, bg_color, grayscale, ignore_size_comparison, fast_mode, jobs

example 1

from optimize_images  import worker
worker("path/to/folder", quality=40)

example 2

from optimize_images  import worker
worker("path/to/image", max_w=1000, max_h=700)

I changed the order of the returning values of 'get_args' _(in argumentparser.py) so that the 'get_args()' (in main.py) return values were coded to be tuple type to the 'args' variable. It is now easier to call 'worker' function without changing the order of values.


Changed init.py and now user can import 'worker' without mentioning like this.

from optimize_images.__main__  import worker

after changed the init.py

from optimize_images  import worker
truethari commented 3 years ago

I closed #32 pull request because 'worker' (function name) is not suitable for this program. I opened a new pull request after changed it.

33