imread
imread(path: str | Path, color_base: str = 'BGR', verbose: bool = False) -> np.ndarray | None
-
Description: Reads an image and returns a BGR numpy image (with optional color conversion).
- If suffix is
.heic: reads viapillow-heif(outputs BGR). - Otherwise: tries
jpgreadfirst (handles JPEG + EXIF orientation), then falls back tocv2.imreadon failure.
- If suffix is
-
Parameters
- path (
str | Path): Image path. - color_base (
str): Output color space. If notBGR, it converts viaimcvtcolor. Default isBGR. - verbose (
bool): IfTrue, warns when the decoded image isNone. Default isFalse.
- path (
-
Returns
- np.ndarray | None: Decoded image, or
Noneon failure.
- np.ndarray | None: Decoded image, or
-
Exceptions
- FileExistsError: When
pathdoes not exist.
- FileExistsError: When
-
Example
import capybara as cb
img = cb.imread('lena.png')