pixel-sizes 0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pixel_sizes/__init__.py +101 -0
- pixel_sizes/_version.py +21 -0
- pixel_sizes/py.typed +0 -0
- pixel_sizes-0.0.dist-info/METADATA +49 -0
- pixel_sizes-0.0.dist-info/RECORD +8 -0
- pixel_sizes-0.0.dist-info/WHEEL +5 -0
- pixel_sizes-0.0.dist-info/licenses/LICENSE +11 -0
- pixel_sizes-0.0.dist-info/top_level.txt +1 -0
pixel_sizes/__init__.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
# https://packaging-guide.openastronomy.org/en/latest/advanced/versioning.html
|
|
5
|
+
from ._version import __version__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class Size:
|
|
10
|
+
"""A class to represent a size in pixels.
|
|
11
|
+
Attributes:
|
|
12
|
+
width (int): The width of the size in pixels.
|
|
13
|
+
height (int): The height of the size in pixels.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
width: int
|
|
17
|
+
height: int
|
|
18
|
+
|
|
19
|
+
def aspect_ratio(self) -> float:
|
|
20
|
+
"""Returns the aspect ratio as a float.
|
|
21
|
+
Example: 1920x1080 => 16/9 => 1.7777777777777777
|
|
22
|
+
"""
|
|
23
|
+
return self.width / self.height
|
|
24
|
+
|
|
25
|
+
def aspect_ratio_two(self) -> tuple[int, int]:
|
|
26
|
+
"""Returns the aspect ratio as a tuple of integers.
|
|
27
|
+
Example: 1920x1080 => (16, 9)
|
|
28
|
+
"""
|
|
29
|
+
gcd = math.gcd(self.width, self.height)
|
|
30
|
+
return self.width // gcd, self.height // gcd
|
|
31
|
+
|
|
32
|
+
def rotate(self) -> "Size":
|
|
33
|
+
"""Returns a new Size object with the width and height swapped.
|
|
34
|
+
Example: 1920x1080 => 1080x1920
|
|
35
|
+
"""
|
|
36
|
+
return Size(self.height, self.width)
|
|
37
|
+
|
|
38
|
+
def scale(self, factor: int) -> "Size":
|
|
39
|
+
"""Returns a new Size object with the width and height scaled by the given factor.
|
|
40
|
+
Example: 1920x1080, factor=2 => 3840x2160
|
|
41
|
+
"""
|
|
42
|
+
return Size(self.width * factor, self.height * factor)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
SIZES = {
|
|
46
|
+
"480p": Size(854, 480),
|
|
47
|
+
"360p": Size(640, 360),
|
|
48
|
+
"240p": Size(426, 240),
|
|
49
|
+
"144p": Size(256, 144),
|
|
50
|
+
"720p": Size(1280, 720),
|
|
51
|
+
"Full HD": Size(1920, 1080),
|
|
52
|
+
"HD 1080p": Size(1920, 1080),
|
|
53
|
+
"1080p": Size(1920, 1080),
|
|
54
|
+
"1080i": Size(1920, 1080),
|
|
55
|
+
"HD": Size(1280, 720),
|
|
56
|
+
"QCIF": Size(176, 144),
|
|
57
|
+
"QVGA": Size(320, 240),
|
|
58
|
+
"HVGA": Size(480, 320),
|
|
59
|
+
"DCGA": Size(640, 400),
|
|
60
|
+
"VGA": Size(640, 480),
|
|
61
|
+
"SVGA": Size(800, 600),
|
|
62
|
+
"WSVGA": Size(1024, 600), # 2 versions
|
|
63
|
+
"DoubleVGA": Size(960, 640),
|
|
64
|
+
"XGA": Size(1024, 768),
|
|
65
|
+
"HD 720p": Size(1280, 720),
|
|
66
|
+
"WXGA": Size(1280, 800),
|
|
67
|
+
"FWXGA": Size(1366, 768),
|
|
68
|
+
"WXGA+": Size(1440, 900),
|
|
69
|
+
"HD+": Size(1600, 900),
|
|
70
|
+
"WXGA++": Size(1600, 900),
|
|
71
|
+
"SXGA+": Size(1400, 1050),
|
|
72
|
+
"WSXGA+": Size(1680, 1050),
|
|
73
|
+
"UXGA": Size(1600, 1200),
|
|
74
|
+
"WQHD": Size(2560, 1440),
|
|
75
|
+
# https://en.wikipedia.org/wiki/2K_resolution
|
|
76
|
+
"DCI 2K": Size(2048, 1080),
|
|
77
|
+
"DCI 2K (flat cropped)": Size(1998, 1080),
|
|
78
|
+
"DCI 2K (CinemaScope cropped)": Size(2048, 858),
|
|
79
|
+
"QXGA": Size(2048, 1536),
|
|
80
|
+
"WQXGA": Size(2560, 1600),
|
|
81
|
+
"WUXGA": Size(1920, 1200),
|
|
82
|
+
"QWXGA": Size(2048, 1152),
|
|
83
|
+
"QUXGA": Size(3200, 2400),
|
|
84
|
+
"QUXGA Wide": Size(3840, 2400),
|
|
85
|
+
# https://en.wikipedia.org/wiki/4K_resolution
|
|
86
|
+
"DCI 4K": Size(4096, 2160),
|
|
87
|
+
"DCI 4K (flat cropped)": Size(3996, 2160),
|
|
88
|
+
"DCI 4K (CinemaScope cropped)": Size(4096, 1716),
|
|
89
|
+
"4K UHD": Size(3840, 2160),
|
|
90
|
+
"4K UHDTV": Size(3840, 2160),
|
|
91
|
+
"UHDTV1": Size(3840, 2160),
|
|
92
|
+
"2160p": Size(3840, 2160),
|
|
93
|
+
# https://en.wikipedia.org/wiki/5K_resolution
|
|
94
|
+
"5K": Size(5120, 2880),
|
|
95
|
+
"5K2K": Size(5120, 2160),
|
|
96
|
+
# https://en.wikipedia.org/wiki/8K_resolution
|
|
97
|
+
"8K UHD": Size(7680, 4320),
|
|
98
|
+
"UHDTV2": Size(7680, 4320),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
__all__ = ["Size", "SIZES", "__version__"]
|
pixel_sizes/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
6
|
+
TYPE_CHECKING = False
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
11
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
12
|
+
else:
|
|
13
|
+
VERSION_TUPLE = object
|
|
14
|
+
|
|
15
|
+
version: str
|
|
16
|
+
__version__: str
|
|
17
|
+
__version_tuple__: VERSION_TUPLE
|
|
18
|
+
version_tuple: VERSION_TUPLE
|
|
19
|
+
|
|
20
|
+
__version__ = version = '0.0'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 0)
|
pixel_sizes/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pixel_sizes
|
|
3
|
+
Version: 0.0
|
|
4
|
+
Summary: Pixel sizes
|
|
5
|
+
Author-email: Yui KITSU <kitsuyui+github@kitsuyui.com>
|
|
6
|
+
License: Copyright 2022-2025 Kitsu Yui
|
|
7
|
+
|
|
8
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
Project-URL: Homepage, https://github.com/kitsuyui/python-pixel-sizes
|
|
19
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# python-pixel-sizes
|
|
33
|
+
|
|
34
|
+
[](https://codecov.io/gh/kitsuyui/python-pixel-sizes)
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from pixel_sizes import SIZES
|
|
40
|
+
|
|
41
|
+
SIZES['Full HD'].width # 1920
|
|
42
|
+
SIZES['Full HD'].height # 1080
|
|
43
|
+
SIZES['Full HD'].aspect_ratio() # 16/9 == 1.7777777777777777
|
|
44
|
+
SIZES['Full HD'].aspect_ratio_two() # (16, 9)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# LICENSE
|
|
48
|
+
|
|
49
|
+
The 3-Clause BSD License. See also LICENSE file.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pixel_sizes/__init__.py,sha256=KP_PomBIo2oqVmtSWiD29vZiuLbsxGwR-_0IMkOmZBM,3167
|
|
2
|
+
pixel_sizes/_version.py,sha256=ZYWThed6jn2lKJF1yxrbl4o_HrbCA9hsBWfm36wo19Q,506
|
|
3
|
+
pixel_sizes/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pixel_sizes-0.0.dist-info/licenses/LICENSE,sha256=Wh1GOCG_4l3WbUm9CC4Qwmez4tixnzRo0Hy6rpJILlA,1459
|
|
5
|
+
pixel_sizes-0.0.dist-info/METADATA,sha256=UkfeC9J13OQLj63OquRqrbNjIUGgIRpaMFBFQMJnCvw,2727
|
|
6
|
+
pixel_sizes-0.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
7
|
+
pixel_sizes-0.0.dist-info/top_level.txt,sha256=AymrlAxrjuN3pLw1axBp74fx0soWqdLBEvNjnghdRtE,12
|
|
8
|
+
pixel_sizes-0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2022-2025 Kitsu Yui
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pixel_sizes
|