ImagePRO-Python 1.0.4__py3-none-any.whl → 1.0.5__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.
ImagePRO/utils/image.py CHANGED
@@ -33,7 +33,7 @@ class Image:
33
33
 
34
34
  Example:
35
35
  >>> # Load from file (default BGR)
36
- >>> img = Image.from_path('input.jpg')
36
+ >>> img = Image.from_path('input.jpg', colorspace="BGR")
37
37
  >>> print(img.shape) # (H, W, 3)
38
38
  >>>
39
39
  >>> # Or wrap a NumPy array
@@ -46,13 +46,19 @@ class Image:
46
46
  source_type: SourceType = "array"
47
47
 
48
48
  @classmethod
49
- def from_path(cls, path: str | Path) -> Image:
49
+ def from_path(
50
+ cls,
51
+ path: str | Path,
52
+ colorspace: Colorspace = "BGR"
53
+ ) -> Image:
50
54
  """
51
55
  Create an Image instance from a file path.
52
56
 
53
57
  Args:
54
58
  path (str | Path):
55
59
  Path to the image file.
60
+ colorspace (Colorspace, optional):
61
+ Colorspace of the image array in that path ("BGR", "RGB", or "GRAY"). Defaults to "BGR".
56
62
 
57
63
  Returns:
58
64
  Image: New Image instance loaded from disk.
@@ -60,13 +66,16 @@ class Image:
60
66
  Raises:
61
67
  TypeError: If path is not str or Path.
62
68
  ValueError: If image cannot be loaded.
69
+ ValueError: If colorspace is invalid.
63
70
  """
64
71
  if not isinstance(path, (str, Path)):
65
72
  raise TypeError("'path' must be a string or pathlib.Path.")
66
73
  np_image = cv2.imread(str(path))
67
74
  if np_image is None:
68
75
  raise ValueError(f"Failed to load image from {path}")
69
- return cls(_data=np_image, path=Path(path), colorspace="BGR", source_type="path")
76
+ if colorspace not in ("BGR", "RGB", "GRAY"):
77
+ raise ValueError("'colorspace' must be one of 'BGR', 'RGB', 'GRAY'.")
78
+ return cls(_data=np_image, path=Path(path), colorspace=colorspace, source_type="path")
70
79
 
71
80
  @classmethod
72
81
  def from_array(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: Professional & modular image processing library with OpenCV, MediaPipe, and YOLO integration.
5
5
  Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
6
6
  License: MIT
@@ -21,10 +21,10 @@ ImagePRO/pre_processing/resize.py,sha256=BGGLGao_1uc8B1kZFa5MVYcTzaeeP1qkjFei6M_
21
21
  ImagePRO/pre_processing/rotate.py,sha256=kdauqCpn71Yube351o1tmQFyxcj2cjTs0ZJflxsoet8,3926
22
22
  ImagePRO/pre_processing/sharpen.py,sha256=kW9KVXvQ77qezBfUWH7loqstQqJ2QvK7s0gtwoxR4EI,3285
23
23
  ImagePRO/utils/__init__.py,sha256=McVd-o9KtKOpAVYbLi19KxsatPPFFF-Qbt0gdgY3Ln8,170
24
- ImagePRO/utils/image.py,sha256=ofzJ5TevUrq8pRwIW7i7zYR4a9IByWPwec1YT4xft3A,3550
24
+ ImagePRO/utils/image.py,sha256=x93cBNycNOgET20a__TxZ9ZQo_2G84uB7QjXjBo9f8M,3973
25
25
  ImagePRO/utils/result.py,sha256=DAFaFZ5jZZ7C2YrhRs6h2PAei6Mbv1Mu8xX_2NQ7c6Y,5605
26
- imagepro_python-1.0.4.dist-info/licenses/LICENSE,sha256=sehkHN7dbe5umrINZJyJjIf9VTemZSgTfJlq6iIsbJQ,1069
27
- imagepro_python-1.0.4.dist-info/METADATA,sha256=PnmPiwygL84z6eC7CrwSlRbQDhGkjklj_0wcCKSZMRM,1618
28
- imagepro_python-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- imagepro_python-1.0.4.dist-info/top_level.txt,sha256=UOuPzsoWrVKXgUupOSI96shJ6wE8Fhz-8bm8oMlLC3s,9
30
- imagepro_python-1.0.4.dist-info/RECORD,,
26
+ imagepro_python-1.0.5.dist-info/licenses/LICENSE,sha256=sehkHN7dbe5umrINZJyJjIf9VTemZSgTfJlq6iIsbJQ,1069
27
+ imagepro_python-1.0.5.dist-info/METADATA,sha256=Qgg5IKxIMyNAbMJ8JBzB5UHx-YPVo-Ibox93zXZFxvE,1618
28
+ imagepro_python-1.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ imagepro_python-1.0.5.dist-info/top_level.txt,sha256=UOuPzsoWrVKXgUupOSI96shJ6wE8Fhz-8bm8oMlLC3s,9
30
+ imagepro_python-1.0.5.dist-info/RECORD,,