Metadata-Version: 2.5
Name: lupaxa-image-converter
Version: 0.1.0
Summary: Convert images between JPG, JPEG, PNG, GIF, WebP, and SVG.
Project-URL: Homepage, https://github.com/lupaxa-miscellaneous-toolbox/image-converter
Project-URL: Repository, https://github.com/lupaxa-miscellaneous-toolbox/image-converter
Project-URL: Issues, https://github.com/lupaxa-miscellaneous-toolbox/image-converter/issues
Author: The Lupaxa Project
License: MIT License
        
        Copyright (c) The Lupaxa Project
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENCE
Keywords: cli,convert,image,pillow,svg,webp
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: cairosvg
Requires-Dist: pillow<13.0,>=12.0
Provides-Extra: dev
Requires-Dist: bump-my-version>=1.2.0; extra == 'dev'
Requires-Dist: mypy>=1.12.0; extra == 'dev'
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-cov>=5.0; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
    <a href="https://github.com/lupaxa-miscellaneous-toolbox">
        <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/miscellaneous-toolbox/readme-logo.png" alt="Organisation Logo" />
    </a>
</p>

<h1 align="center">Image Converter</h1>

Convert an image from one format to another: JPG, JPEG, PNG, GIF, WebP, and SVG.

Raster formats are converted with Pillow. SVG input is rasterised with CairoSVG.
A raster image converted to SVG is embedded in an SVG document.

> **Note:** Embedding a raster image in SVG does not vectorise it.

## Install

Python 3.10 or newer. The PyPI package name is `lupaxa-image-converter`.
The console command is `image-converter`.

SVG input also needs the system Cairo library (`brew install cairo` on macOS,
or `apt install libcairo2` on Debian/Ubuntu).

```bash
python -m pip install lupaxa-image-converter
```

From a clone, for development:

```bash
python -m pip install -e ".[dev]"
```

## Use

```bash
image-converter photo.png photo.webp
image-converter photo.png --format webp
image-converter logo.svg --format png
```

The same commands work as a module:

```bash
python -m lupaxa.image_converter photo.png --format webp
```

`--format` writes the result next to the input, using the input name and the
new suffix. Pass an output path when the file should live somewhere else.
If you pass both, the output suffix must match `--format`.

JPEG output flattens transparency onto white. `--quality` applies to JPEG
and WebP (default 90).

## CLI Options

Run `image-converter --help` for the authoritative list from your installed
version.

| Option             | Default      | Description                                      |
| :----------------- | :----------- | :----------------------------------------------- |
| `input`            | *(required)* | Input image.                                     |
| `output`           |              | Output image. Optional when `--format` is used.  |
| `-f` / `--format`  |              | `jpg`, `jpeg`, `png`, `gif`, `webp`, or `svg`.   |
| `-q` / `--quality` | `90`         | JPEG and WebP quality from 1 to 100.             |

## Testing

```bash
make init
make python-install-dev
make python-check
```

Or without Make:

```bash
python -m pip install -e ".[test]"
pytest
```

Coverage for `lupaxa.image_converter` is reported by default. SVG tests run
when native Cairo is available and skip otherwise:

```bash
pytest -m cairo
```

<a href="https://github.com/the-lupaxa-project">
    <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
</a>
