Repository: imageio/imageio

Issue:
AttributeError: 'SeekableFileObject' object has no attribute 'readline'
trouble occur when reading some website address as follow, but same address is ok by skimage.io import imread:

  File "/usr/local/lib/python3.8/site-packages/imageio/v2.py", line 359, in imread
    with imopen(uri, "ri", **imopen_args) as file:
  File "/usr/local/lib/python3.8/site-packages/imageio/core/imopen.py", line 196, in imopen
    plugin_instance = candidate_plugin(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/imageio/plugins/pillow.py", line 104, in __init__
    with Image.open(request.get_file()):
  File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 3133, in open
    im = _open_core(fp, filename, prefix, formats)
  File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 3119, in _open_core
    im = factory(fp, filename)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFile.py", line 116, in __init__
    self._open()
  File "/usr/local/lib/python3.8/site-packages/PIL/ImImagePlugin.py", line 153, in _open
    s = s + self.fp.readline()
AttributeError: 'SeekableFileObject' object has no attribute 'readline'


Discussion:
Pandede: I admit it is pretty weird about [this image](https://imagenes.20minutos.es/files/image_1920_1080/uploads/imagenes/2022/09/09/fotografia-a-coruna.jpeg): it has JPEG extension, but it is actually a WebP image.
However, when `Pillow` loads this image, it is recognized as an [IM image](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#im) and loads it with `Pillow.ImImagePlugin`, which requires the input file object supports `readline` (https://github.com/python-pillow/Pillow/blob/main/src/PIL/ImImagePlugin.py#L151).
Therefore, I may use the [IM testing image](https://github.com/python-pillow/Pillow/blob/main/Tests/images/hopper_long_name.im) of `Pillow`.
Pandede: I may reproduce the bug with [this test image](https://github.com/python-pillow/Pillow/raw/main/Tests/images/hopper_orientation_2.webp) of `Pillow`.
Note that although the extension of [this image](https://imagenes.20minutos.es/files/image_1920_1080/uploads/imagenes/2022/09/09/fotografia-a-coruna.jpeg) (fotografia-a-coruna.jpeg) is JPEG, it is actually a WebP image.
Pandede: It seems like `pillow` cannot to read WebP image as the missing package `libwebp-dev`.

Patch:
diff --git a/imageio/core/request.py b/imageio/core/request.py
index f42da19..47b7c95 100644
--- a/imageio/core/request.py
+++ b/imageio/core/request.py
@@ -697,6 +697,9 @@ class SeekableFileObject:
 
         return res
 
+    def readline(self):
+        yield from self._file.readline()
+
     def tell(self):
         return self._i
 


Test patch:
diff --git a/tests/test_pillow.py b/tests/test_pillow.py
index b4ddff2..77657dc 100644
--- a/tests/test_pillow.py
+++ b/tests/test_pillow.py
@@ -719,3 +719,13 @@ def test_avif_remote():
     url = "https://github.com/link-u/avif-sample-images/raw/master/fox.profile0.10bpc.yuv420.avif"
     im = iio.imread(url, plugin="pillow")
     assert im.shape == (800, 1204, 3)
+
+
+@pytest.mark.needs_internet
+def test_webp_remote():
+    # this is a regression test for
+    # https://github.com/imageio/imageio/issues/1065
+    # the image in the issue is actually a webp image
+    url = "https://github.com/python-pillow/Pillow/raw/main/Tests/images/hopper_orientation_2.webp"
+    im = iio.imread(url, plugin="pillow")
+    assert im.shape == (128, 128, 3)