get_image_dimensions
Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state.
def get_image_dimensions(
file_or_path: file-like object or string,
close: boolean = False
) - > tuple
Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state.
Parameters
| Name | Type | Description |
|---|---|---|
| file_or_path | file-like object or string | An open file-like object or a filesystem path to the image file to be analyzed. |
| close | boolean = False | Whether to close the file after reading; if False and a file-like object was provided, the file pointer is reset to its original position. |
Returns
| Type | Description |
|---|---|
tuple | A tuple containing (width, height) in pixels, or (None, None) if the dimensions could not be determined or the file is invalid. |