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: Any minimum code which can reproduce this error?@FranPuentes: For example:

import imageio;

# Cargar una imagen
info = imageio.v3.improps("https://imagenes.20minutos.es/files/image_1920_1080/uploads/imagenes/2022/09/09/fotografia-a-coruna.jpeg")
info


Solution 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)