Metadata-Version: 2.4
Name: pixel_sizes
Version: 0.4.0
Summary: Pixel sizes
Author-email: Yui KITSU <kitsuyui+github@kitsuyui.com>
License: Copyright 2022-2025 Kitsu Yui
        
        Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/kitsuyui/python-pixel-sizes
Classifier: License :: OSI Approved :: BSD License
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: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# python-pixel-sizes

![Coverage](https://raw.githubusercontent.com/kitsuyui/octocov-central/main/badges/kitsuyui/python-pixel-sizes/coverage.svg)

## Usage

```python
from pixel_sizes import SIZES

SIZES['Full HD'].width   # 1920
SIZES['Full HD'].height  # 1080
SIZES['Full HD'].aspect_ratio()    # 16/9 == 1.7777777777777777
SIZES['Full HD'].aspect_ratio_fraction()  # (16, 9)
SIZES['Full HD'].rotate()  # Size(width=1080, height=1920)
SIZES['Full HD'].scale(2)  # Size(width=3840, height=2160)
```

## API

### `Size`

| Attribute / Method | Description |
| --- | --- |
| `width: int` | Width in pixels |
| `height: int` | Height in pixels |
| `aspect_ratio() -> float` | Width / height as a float |
| `aspect_ratio_fraction() -> tuple[int, int]` | Aspect ratio reduced to lowest terms, e.g. `(16, 9)` |
| `rotate() -> Size` | New `Size` with width and height swapped |
| `scale(factor: int \| float) -> Size` | New `Size` multiplied by *factor* |

### `SIZES`

A read-only mapping of type `Mapping[str, Size]` containing named display
resolutions. Attempting to assign or delete entries raises `TypeError`.
Representative keys (full list in source):

```python
"480p", "720p", "1080p", "Full HD", "HD 1080p",
"WQHD", "4K UHD", "8K UHD", ...
```

Iterate all available names:

```python
from pixel_sizes import SIZES
list(SIZES.keys())
```

## Development

This repository uses [lefthook](https://lefthook.dev/) to run the same checks as CI
locally, so problems surface before they reach CI.

```sh
# Install dependencies
uv sync

# Install the Git hooks (once; requires lefthook on your PATH)
lefthook install
```

Once installed, the hooks run automatically:

- **pre-commit**: `uv run poe check`
- **pre-push**: `uv run poe check` and `uv run poe test`

You can also run the checks manually:

```sh
uv run poe check
uv run poe test
```

CI still runs the full matrix (see `.github/workflows/`); the hooks only bring that
feedback earlier on your machine.

# LICENSE

The 3-Clause BSD License. See also LICENSE file.
