@@ -1425,6 +1425,11 @@ def imread(fname, format=None):
1425
1425
"""
1426
1426
Read an image from a file into an array.
1427
1427
1428
+ .. note::
1429
+
1430
+ This function exists for historical reasons. It is recommended to
1431
+ use `PIL.Image.open` instead for loading images.
1432
+
1428
1433
Parameters
1429
1434
----------
1430
1435
fname : str or file-like
@@ -1435,9 +1440,11 @@ def imread(fname, format=None):
1435
1440
for reading and pass the result to Pillow, e.g. with
1436
1441
``PIL.Image.open(urllib.request.urlopen(url))``.
1437
1442
format : str, optional
1438
- The image file format assumed for reading the data. If not
1439
- given, the format is deduced from the filename. If nothing can
1440
- be deduced, PNG is tried.
1443
+ The image file format assumed for reading the data. The image is
1444
+ loaded as a PNG file if *format* is set to "png", if *fname* is a path
1445
+ or opened file with a ".png" extension, or if it is an URL. In all
1446
+ other cases, *format* is ignored and the format is auto-detected by
1447
+ `PIL.Image.open`.
1441
1448
1442
1449
Returns
1443
1450
-------
@@ -1447,6 +1454,10 @@ def imread(fname, format=None):
1447
1454
- (M, N) for grayscale images.
1448
1455
- (M, N, 3) for RGB images.
1449
1456
- (M, N, 4) for RGBA images.
1457
+
1458
+ PNG images are returned as float arrays (0-1). All other formats are
1459
+ returned as int arrays, with a bit depth determined by the file's
1460
+ contents.
1450
1461
"""
1451
1462
# hide imports to speed initial import on systems with slow linkers
1452
1463
from urllib import parse
0 commit comments