prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  tifffile: try to use the one in the user's install first
  Should we try importing tifffile before using the one we versionned it?
  
  </issue>
  <code>
  [start of skimage/io/_plugins/tifffile_plugin.py]
  1 from ...external.tifffile import TiffFile, imsave, parse_kwargs
  2 
  3 
  4 def imread(fname, dtype=None, **kwargs):
  5     """Load a tiff image from file.
  6 
  7     Parameters
  8     ----------
  9     fname : str or file
  10        File name or file-like-object.
  11     dtype : numpy dtype object or string specifier
  12        Specifies data type of array elements (Not currently used).
  13     kwargs : keyword pairs, optional
  14         Additional keyword arguments to pass through (see ``tifffile``'s
  15         ``imread`` function).
  16 
  17     Notes
  18     -----
  19     Provided by Christophe Golhke's tifffile.py [1]_, and supports many
  20     advanced image types including multi-page and floating point.
  21 
  22     References
  23     ----------
  24     .. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py
  25 
  26     """
  27 
  28     if 'img_num' in kwargs:
  29         kwargs['key'] = kwargs.pop('img_num')
  30 
  31     # parse_kwargs will extract keyword arguments intended for the TiffFile 
  32     # class and remove them from the kwargs dictionary in-place
  33     tiff_keys = ['multifile', 'multifile_close', 'pages', 'fastij', 'is_ome']
  34     kwargs_tiff = parse_kwargs(kwargs, *tiff_keys)
  35 
  36     # read and return tiff as numpy array
  37     with TiffFile(fname, **kwargs_tiff) as tif:
  38         return tif.asarray(**kwargs)
  39
  [end of skimage/io/_plugins/tifffile_plugin.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/skimage/io/_plugins/tifffile_plugin.py b/skimage/io/_plugins/tifffile_plugin.py
  --- a/skimage/io/_plugins/tifffile_plugin.py
  +++ b/skimage/io/_plugins/tifffile_plugin.py
  @@ -1,4 +1,7 @@
  -from ...external.tifffile import TiffFile, imsave, parse_kwargs
  +try:
  +    from tifffile import TiffFile, imsave, parse_kwargs
  +except ImportError:
  +    from ...external.tifffile import TiffFile, imsave, parse_kwargs
   
   
   def imread(fname, dtype=None, **kwargs):
  
verification_info: {"golden_diff": "diff --git a/skimage/io/_plugins/tifffile_plugin.py b/skimage/io/_plugins/tifffile_plugin.py\n--- a/skimage/io/_plugins/tifffile_plugin.py\n+++ b/skimage/io/_plugins/tifffile_plugin.py\n@@ -1,4 +1,7 @@\n-from ...external.tifffile import TiffFile, imsave, parse_kwargs\n+try:\n+    from tifffile import TiffFile, imsave, parse_kwargs\n+except ImportError:\n+    from ...external.tifffile import TiffFile, imsave, parse_kwargs\n \n \n def imread(fname, dtype=None, **kwargs):\n", "issue": "tifffile: try to use the one in the user's install first\nShould we try importing tifffile before using the one we versionned it?\n", "before_files": [{"content": "from ...external.tifffile import TiffFile, imsave, parse_kwargs\n\n\ndef imread(fname, dtype=None, **kwargs):\n    \"\"\"Load a tiff image from file.\n\n    Parameters\n    ----------\n    fname : str or file\n       File name or file-like-object.\n    dtype : numpy dtype object or string specifier\n       Specifies data type of array elements (Not currently used).\n    kwargs : keyword pairs, optional\n        Additional keyword arguments to pass through (see ``tifffile``'s\n        ``imread`` function).\n\n    Notes\n    -----\n    Provided by Christophe Golhke's tifffile.py [1]_, and supports many\n    advanced image types including multi-page and floating point.\n\n    References\n    ----------\n    .. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py\n\n    \"\"\"\n\n    if 'img_num' in kwargs:\n        kwargs['key'] = kwargs.pop('img_num')\n\n    # parse_kwargs will extract keyword arguments intended for the TiffFile \n    # class and remove them from the kwargs dictionary in-place\n    tiff_keys = ['multifile', 'multifile_close', 'pages', 'fastij', 'is_ome']\n    kwargs_tiff = parse_kwargs(kwargs, *tiff_keys)\n\n    # read and return tiff as numpy array\n    with TiffFile(fname, **kwargs_tiff) as tif:\n        return tif.asarray(**kwargs)\n", "path": "skimage/io/_plugins/tifffile_plugin.py"}]}