Unverified Commit 9e8258d1 authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Fix for rotate fill with Images of type F (#1828)

parent 30538b5d
...@@ -1078,7 +1078,7 @@ class Tester(unittest.TestCase): ...@@ -1078,7 +1078,7 @@ class Tester(unittest.TestCase):
def test_rotate_fill(self): def test_rotate_fill(self):
img = F.to_pil_image(np.ones((100, 100, 3), dtype=np.uint8) * 255, "RGB") img = F.to_pil_image(np.ones((100, 100, 3), dtype=np.uint8) * 255, "RGB")
modes = ("L", "RGB") modes = ("L", "RGB", "F")
nums_bands = [len(mode) for mode in modes] nums_bands = [len(mode) for mode in modes]
fill = 127 fill = 127
......
...@@ -725,9 +725,9 @@ def rotate(img, angle, resample=False, expand=False, center=None, fill=None): ...@@ -725,9 +725,9 @@ def rotate(img, angle, resample=False, expand=False, center=None, fill=None):
if fill is None: if fill is None:
fill = 0 fill = 0
if isinstance(fill, (int, float)): if isinstance(fill, (int, float)) and num_bands > 1:
fill = tuple([fill] * num_bands) fill = tuple([fill] * num_bands)
if len(fill) != num_bands: if not isinstance(fill, (int, float)) and len(fill) != num_bands:
msg = ("The number of elements in 'fill' does not match the number of " msg = ("The number of elements in 'fill' does not match the number of "
"bands of the image ({} != {})") "bands of the image ({} != {})")
raise ValueError(msg.format(len(fill), num_bands)) raise ValueError(msg.format(len(fill), num_bands))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment