Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/biohzrdmx/kompressor-cli

Resize zipped image galleries
https://github.com/biohzrdmx/kompressor-cli

Last synced: about 2 months ago
JSON representation

Resize zipped image galleries

Awesome Lists containing this project

README

        

# kompressor-cli

Resize zipped image galleries.

## Requirements

- PHP 8.2+
- GD extension enabled
- ZIP extension enabled
- Composer (for development)

## Installation

Grab the latest `kompressor.phar` from the [releases page](https://github.com/biohzrdmx/kompressor-cli/releases/latest).

Most likely, you'll want to put the `kompressor.phar` into a directory on your `PATH`, so you can simply call `kompressor` from any directory, using for example:

**On Linux**

```bash
sudo mv kompressor.phar /usr/local/bin/kompressor
```

Don't forget to make it executable.

**On Windows**

The easiest way is to use a `cmd` wrapper, put `kompressor.phar` in a directory under your `PATH` and create a file named `kompressor.cmd` in the same directory with the following contents:

```bash
@php "%~dp0kompressor.phar" %*
```

Now you just have to call `kompressor` from the command line.

## Basic usage

Just pass a ZIP file:

```bash
kompressor photos.zip
```

By default it will try to resize all the JPG images proportionally (keeping aspect ratio) to 1200 px. on its longer side, with a 90% compression quality.

You can change these values by using the `--size` and `--quality` arguments:

```bash
kompressor --size=1600 --quality=85 ~/photos.zip
```

The resulting file will have `-proc` suffixed to its file name, for example `~/photos.zip` will generate `~/photos-proc.zip`.

## Directory mode

You may also pass a directory path and Kompressor will process all the ZIP files inside (without recursion):

```bash
kompressor ~/albums
```

It can be combined with size/quality flags:

```bash
kompressor --size=1280 --quality=95 ~/albums
```

## File list mode

And you may even pass a file list, to do so create a TXT file with a ZIP path on each line, for example on `files.txt`:

```
~/vacation.zip
~/wedding.zip
~/birthday.zip
```

Then just pass its path to the `kompressor` command:

```bash
kompressor --list ~/files.txt
```

As usual, you may pass size/quality options too:

```bash
kompressor --size=800 --quality=95 --list ~/files.txt
```

## Advanced usage

### Change the suffix

To change the default suffix use the `--suffix` flag like so:

```bash
kompressor --suffix=resized ~/photos.zip
```

Finally you can filter out garbage files (mostly generated by MacOS) with the `--skip` toggle:

```bash
kompressor --skip ~/photos.zip
```

These two flags work with both directory and file list modes and also with the size/quality flags:

```bash
kompressor --size=800 --quality=95 --suffix=resized --skip ~/albums
```

## Building the PHAR file

This project uses [Box](https://github.com/box-project/box), so that you just need to run:

```bash
box compile
```

The resulting PHAR will be generated on the `/build` directory.

## Known limitations

- Just works with ZIP archives (RAR/TAR/7ZIP/etc are not supported)
- Just works with JPG images inside the archives (PNG/TIFF/TGA/etc are not supported)
- Does not create ZIP galleries, only resizes them
- Tested only on Windows
- Tested with galleries up to 400 MB in size
- Tested with galleries which contain images up to 4000x2256 px @ 95% quality

## Contributing

Clone the repo, make your changes and submit a pull-request; issues are welcomed too, but this is a side project, so response times may not be ideal.

## License

MIT licensed

## Copyright

Copyright © 2024 biohzrdmx. All rights reserved