We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ImageView doesn't shrink images to fit
### Describe the bug

The documentation for ImageView says that a `flex=1` image will be expanded or shrunk to fit the available space. It definitely expands images to fit, but a large image will not be *shrunk* to fit.

### Steps to reproduce

Use the following app code:
```py
        main_box = toga.Box(style=Pack(direction=ROW))

        main_box.add(toga.ImageView("image.png", style=Pack(flex=1)))

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
```

if image.png is smaller than the window, it will be expanded; if image.py is larger than the window, the window will be expanded to fit the natural size of the window (or, on mobile, show "content doesn't fit window" warnings).


### Expected behavior

An ImageView with `flex=1` should shrink large images to fit the available space, preserving aspect ratio.

### Screenshots

_No response_

### Environment

- Operating System: all (tested on macOS and iOS)
- Python version: All
- Software versions:
  - Toga: 0.4.0


### Logs

_No response_

### Additional context

The underlying problem appears to be that the intrinsic constraint has been set to `at_least(size)` in each axis, rather than `at_least(0)`. This enforces a minimum size that can't be shrunk.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `core/src/toga/widgets/imageview.py`
Content:
```
1 from __future__ import annotations
2 
3 from typing import TYPE_CHECKING
4 
5 from travertino.size import at_least
6 
7 import toga
8 from toga.style.pack import NONE
9 from toga.widgets.base import Widget
10 
11 if TYPE_CHECKING:
12     from pathlib import Path
13 
14     import PIL.Image
15 
16     from toga.images import ImageT
17 
18 
19 def rehint_imageview(image, style, scale=1):
20     """Compute the size hints for an ImageView based on the image.
21 
22     This logic is common across all backends, so it's shared here.
23 
24     :param image: The image being displayed.
25     :param style: The style object for the imageview.
26     :param scale: The scale factor (if any) to apply to native pixel sizes.
27     :returns: A triple containing the intrinsic width hint, intrinsic height
28         hint, and the aspect ratio to preserve (or None if the aspect ratio
29         should not be preserved).
30     """
31     if image:
32         if style.width != NONE and style.height != NONE:
33             # Explicit width and height for image. Scale the rendered image
34             # to fit the explicitly provided size.
35             width = int(style.width * scale)
36             height = int(style.height * scale)
37             aspect_ratio = None
38 
39         elif style.width != NONE:
40             # Explicit width, implicit height. Preserve aspect ratio.
41             aspect_ratio = image.width / image.height
42             width = int(style.width * scale)
43             height = int(style.width * scale / aspect_ratio)
44             if style.flex:
45                 height = at_least(height)
46         elif style.height != NONE:
47             # Explicit height, implicit width. Preserve aspect ratio.
48             aspect_ratio = image.width / image.height
49             width = int(style.height * scale * aspect_ratio)
50             height = int(style.height * scale)
51             if style.flex:
52                 width = at_least(width)
53         else:
54             # Use the image's actual size.
55             aspect_ratio = image.width / image.height
56             width = int(image.width * scale)
57             height = int(image.height * scale)
58             if style.flex:
59                 width = at_least(width)
60                 height = at_least(height)
61     else:
62         # No image. Hinted size is 0.
63         width = 0
64         height = 0
65         aspect_ratio = None
66 
67     return width, height, aspect_ratio
68 
69 
70 # Note: remove PIL type annotation when plugin system is implemented for image format
71 # registration; replace with ImageT?
72 class ImageView(Widget):
73     def __init__(
74         self,
75         image: str
76         | Path
77         | bytes
78         | bytearray
79         | memoryview
80         | PIL.Image.Image
81         | None = None,
82         id=None,
83         style=None,
84     ):
85         """
86         Create a new image view.
87 
88         :param image: The image to display. This can take all the same formats as the
89             `src` parameter to :class:`toga.Image` -- namely, a file path (as string
90             or :any:`pathlib.Path`), bytes data in a supported image format,
91             or :any:`PIL.Image.Image`.
92         :param id: The ID for the widget.
93         :param style: A style object. If no style is provided, a default style will be
94             applied to the widget.
95         """
96         super().__init__(id=id, style=style)
97         # Prime the image attribute
98         self._image = None
99         self._impl = self.factory.ImageView(interface=self)
100         self.image = image
101 
102     @property
103     def enabled(self) -> bool:
104         """Is the widget currently enabled? i.e., can the user interact with the widget?
105 
106         ImageView widgets cannot be disabled; this property will always return True; any
107         attempt to modify it will be ignored.
108         """
109         return True
110 
111     @enabled.setter
112     def enabled(self, value):
113         pass
114 
115     def focus(self):
116         "No-op; ImageView cannot accept input focus"
117         pass
118 
119     @property
120     def image(self) -> toga.Image | None:
121         """The image to display.
122 
123         When setting an image, you can provide:
124 
125         * An :class:`~toga.images.Image` instance; or
126 
127         * Any value that would be a valid path specifier when creating a new
128           :class:`~toga.images.Image` instance; or
129 
130         * :any:`None` to clear the image view.
131         """
132         return self._image
133 
134     @image.setter
135     def image(self, image):
136         if isinstance(image, toga.Image):
137             self._image = image
138         elif image is None:
139             self._image = None
140         else:
141             self._image = toga.Image(image)
142 
143         self._impl.set_image(self._image)
144         self.refresh()
145 
146     def as_image(self, format: type[ImageT] = toga.Image) -> ImageT:
147         """Return the image in the specified format.
148 
149         :param format: Format to provide. Defaults to :class:`~toga.images.Image`; also
150             supports :any:`PIL.Image.Image` if Pillow is installed.
151         :returns: The image in the specified format.
152         """
153         return self.image.as_format(format)
154
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/core/src/toga/widgets/imageview.py b/core/src/toga/widgets/imageview.py
--- a/core/src/toga/widgets/imageview.py
+++ b/core/src/toga/widgets/imageview.py
@@ -42,22 +42,22 @@
             width = int(style.width * scale)
             height = int(style.width * scale / aspect_ratio)
             if style.flex:
-                height = at_least(height)
+                height = at_least(0)
         elif style.height != NONE:
             # Explicit height, implicit width. Preserve aspect ratio.
             aspect_ratio = image.width / image.height
             width = int(style.height * scale * aspect_ratio)
             height = int(style.height * scale)
             if style.flex:
-                width = at_least(width)
+                width = at_least(0)
         else:
             # Use the image's actual size.
             aspect_ratio = image.width / image.height
             width = int(image.width * scale)
             height = int(image.height * scale)
             if style.flex:
-                width = at_least(width)
-                height = at_least(height)
+                width = at_least(0)
+                height = at_least(0)
     else:
         # No image. Hinted size is 0.
         width = 0

{"golden_diff": "diff --git a/core/src/toga/widgets/imageview.py b/core/src/toga/widgets/imageview.py\n--- a/core/src/toga/widgets/imageview.py\n+++ b/core/src/toga/widgets/imageview.py\n@@ -42,22 +42,22 @@\n             width = int(style.width * scale)\n             height = int(style.width * scale / aspect_ratio)\n             if style.flex:\n-                height = at_least(height)\n+                height = at_least(0)\n         elif style.height != NONE:\n             # Explicit height, implicit width. Preserve aspect ratio.\n             aspect_ratio = image.width / image.height\n             width = int(style.height * scale * aspect_ratio)\n             height = int(style.height * scale)\n             if style.flex:\n-                width = at_least(width)\n+                width = at_least(0)\n         else:\n             # Use the image's actual size.\n             aspect_ratio = image.width / image.height\n             width = int(image.width * scale)\n             height = int(image.height * scale)\n             if style.flex:\n-                width = at_least(width)\n-                height = at_least(height)\n+                width = at_least(0)\n+                height = at_least(0)\n     else:\n         # No image. Hinted size is 0.\n         width = 0\n", "issue": "ImageView doesn't shrink images to fit\n### Describe the bug\r\n\r\nThe documentation for ImageView says that a `flex=1` image will be expanded or shrunk to fit the available space. It definitely expands images to fit, but a large image will not be *shrunk* to fit.\r\n\r\n### Steps to reproduce\r\n\r\nUse the following app code:\r\n```py\r\n        main_box = toga.Box(style=Pack(direction=ROW))\r\n\r\n        main_box.add(toga.ImageView(\"image.png\", style=Pack(flex=1)))\r\n\r\n        self.main_window = toga.MainWindow(title=self.formal_name)\r\n        self.main_window.content = main_box\r\n        self.main_window.show()\r\n```\r\n\r\nif image.png is smaller than the window, it will be expanded; if image.py is larger than the window, the window will be expanded to fit the natural size of the window (or, on mobile, show \"content doesn't fit window\" warnings).\r\n\r\n\r\n### Expected behavior\r\n\r\nAn ImageView with `flex=1` should shrink large images to fit the available space, preserving aspect ratio.\r\n\r\n### Screenshots\r\n\r\n_No response_\r\n\r\n### Environment\r\n\r\n- Operating System: all (tested on macOS and iOS)\r\n- Python version: All\r\n- Software versions:\r\n  - Toga: 0.4.0\r\n\r\n\r\n### Logs\r\n\r\n_No response_\r\n\r\n### Additional context\r\n\r\nThe underlying problem appears to be that the intrinsic constraint has been set to `at_least(size)` in each axis, rather than `at_least(0)`. This enforces a minimum size that can't be shrunk.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom travertino.size import at_least\n\nimport toga\nfrom toga.style.pack import NONE\nfrom toga.widgets.base import Widget\n\nif TYPE_CHECKING:\n    from pathlib import Path\n\n    import PIL.Image\n\n    from toga.images import ImageT\n\n\ndef rehint_imageview(image, style, scale=1):\n    \"\"\"Compute the size hints for an ImageView based on the image.\n\n    This logic is common across all backends, so it's shared here.\n\n    :param image: The image being displayed.\n    :param style: The style object for the imageview.\n    :param scale: The scale factor (if any) to apply to native pixel sizes.\n    :returns: A triple containing the intrinsic width hint, intrinsic height\n        hint, and the aspect ratio to preserve (or None if the aspect ratio\n        should not be preserved).\n    \"\"\"\n    if image:\n        if style.width != NONE and style.height != NONE:\n            # Explicit width and height for image. Scale the rendered image\n            # to fit the explicitly provided size.\n            width = int(style.width * scale)\n            height = int(style.height * scale)\n            aspect_ratio = None\n\n        elif style.width != NONE:\n            # Explicit width, implicit height. Preserve aspect ratio.\n            aspect_ratio = image.width / image.height\n            width = int(style.width * scale)\n            height = int(style.width * scale / aspect_ratio)\n            if style.flex:\n                height = at_least(height)\n        elif style.height != NONE:\n            # Explicit height, implicit width. Preserve aspect ratio.\n            aspect_ratio = image.width / image.height\n            width = int(style.height * scale * aspect_ratio)\n            height = int(style.height * scale)\n            if style.flex:\n                width = at_least(width)\n        else:\n            # Use the image's actual size.\n            aspect_ratio = image.width / image.height\n            width = int(image.width * scale)\n            height = int(image.height * scale)\n            if style.flex:\n                width = at_least(width)\n                height = at_least(height)\n    else:\n        # No image. Hinted size is 0.\n        width = 0\n        height = 0\n        aspect_ratio = None\n\n    return width, height, aspect_ratio\n\n\n# Note: remove PIL type annotation when plugin system is implemented for image format\n# registration; replace with ImageT?\nclass ImageView(Widget):\n    def __init__(\n        self,\n        image: str\n        | Path\n        | bytes\n        | bytearray\n        | memoryview\n        | PIL.Image.Image\n        | None = None,\n        id=None,\n        style=None,\n    ):\n        \"\"\"\n        Create a new image view.\n\n        :param image: The image to display. This can take all the same formats as the\n            `src` parameter to :class:`toga.Image` -- namely, a file path (as string\n            or :any:`pathlib.Path`), bytes data in a supported image format,\n            or :any:`PIL.Image.Image`.\n        :param id: The ID for the widget.\n        :param style: A style object. If no style is provided, a default style will be\n            applied to the widget.\n        \"\"\"\n        super().__init__(id=id, style=style)\n        # Prime the image attribute\n        self._image = None\n        self._impl = self.factory.ImageView(interface=self)\n        self.image = image\n\n    @property\n    def enabled(self) -> bool:\n        \"\"\"Is the widget currently enabled? i.e., can the user interact with the widget?\n\n        ImageView widgets cannot be disabled; this property will always return True; any\n        attempt to modify it will be ignored.\n        \"\"\"\n        return True\n\n    @enabled.setter\n    def enabled(self, value):\n        pass\n\n    def focus(self):\n        \"No-op; ImageView cannot accept input focus\"\n        pass\n\n    @property\n    def image(self) -> toga.Image | None:\n        \"\"\"The image to display.\n\n        When setting an image, you can provide:\n\n        * An :class:`~toga.images.Image` instance; or\n\n        * Any value that would be a valid path specifier when creating a new\n          :class:`~toga.images.Image` instance; or\n\n        * :any:`None` to clear the image view.\n        \"\"\"\n        return self._image\n\n    @image.setter\n    def image(self, image):\n        if isinstance(image, toga.Image):\n            self._image = image\n        elif image is None:\n            self._image = None\n        else:\n            self._image = toga.Image(image)\n\n        self._impl.set_image(self._image)\n        self.refresh()\n\n    def as_image(self, format: type[ImageT] = toga.Image) -> ImageT:\n        \"\"\"Return the image in the specified format.\n\n        :param format: Format to provide. Defaults to :class:`~toga.images.Image`; also\n            supports :any:`PIL.Image.Image` if Pillow is installed.\n        :returns: The image in the specified format.\n        \"\"\"\n        return self.image.as_format(format)\n", "path": "core/src/toga/widgets/imageview.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom travertino.size import at_least\n\nimport toga\nfrom toga.style.pack import NONE\nfrom toga.widgets.base import Widget\n\nif TYPE_CHECKING:\n    from pathlib import Path\n\n    import PIL.Image\n\n    from toga.images import ImageT\n\n\ndef rehint_imageview(image, style, scale=1):\n    \"\"\"Compute the size hints for an ImageView based on the image.\n\n    This logic is common across all backends, so it's shared here.\n\n    :param image: The image being displayed.\n    :param style: The style object for the imageview.\n    :param scale: The scale factor (if any) to apply to native pixel sizes.\n    :returns: A triple containing the intrinsic width hint, intrinsic height\n        hint, and the aspect ratio to preserve (or None if the aspect ratio\n        should not be preserved).\n    \"\"\"\n    if image:\n        if style.width != NONE and style.height != NONE:\n            # Explicit width and height for image. Scale the rendered image\n            # to fit the explicitly provided size.\n            width = int(style.width * scale)\n            height = int(style.height * scale)\n            aspect_ratio = None\n\n        elif style.width != NONE:\n            # Explicit width, implicit height. Preserve aspect ratio.\n            aspect_ratio = image.width / image.height\n            width = int(style.width * scale)\n            height = int(style.width * scale / aspect_ratio)\n            if style.flex:\n                height = at_least(0)\n        elif style.height != NONE:\n            # Explicit height, implicit width. Preserve aspect ratio.\n            aspect_ratio = image.width / image.height\n            width = int(style.height * scale * aspect_ratio)\n            height = int(style.height * scale)\n            if style.flex:\n                width = at_least(0)\n        else:\n            # Use the image's actual size.\n            aspect_ratio = image.width / image.height\n            width = int(image.width * scale)\n            height = int(image.height * scale)\n            if style.flex:\n                width = at_least(0)\n                height = at_least(0)\n    else:\n        # No image. Hinted size is 0.\n        width = 0\n        height = 0\n        aspect_ratio = None\n\n    return width, height, aspect_ratio\n\n\n# Note: remove PIL type annotation when plugin system is implemented for image format\n# registration; replace with ImageT?\nclass ImageView(Widget):\n    def __init__(\n        self,\n        image: str\n        | Path\n        | bytes\n        | bytearray\n        | memoryview\n        | PIL.Image.Image\n        | None = None,\n        id=None,\n        style=None,\n    ):\n        \"\"\"\n        Create a new image view.\n\n        :param image: The image to display. This can take all the same formats as the\n            `src` parameter to :class:`toga.Image` -- namely, a file path (as string\n            or :any:`pathlib.Path`), bytes data in a supported image format,\n            or :any:`PIL.Image.Image`.\n        :param id: The ID for the widget.\n        :param style: A style object. If no style is provided, a default style will be\n            applied to the widget.\n        \"\"\"\n        super().__init__(id=id, style=style)\n        # Prime the image attribute\n        self._image = None\n        self._impl = self.factory.ImageView(interface=self)\n        self.image = image\n\n    @property\n    def enabled(self) -> bool:\n        \"\"\"Is the widget currently enabled? i.e., can the user interact with the widget?\n\n        ImageView widgets cannot be disabled; this property will always return True; any\n        attempt to modify it will be ignored.\n        \"\"\"\n        return True\n\n    @enabled.setter\n    def enabled(self, value):\n        pass\n\n    def focus(self):\n        \"No-op; ImageView cannot accept input focus\"\n        pass\n\n    @property\n    def image(self) -> toga.Image | None:\n        \"\"\"The image to display.\n\n        When setting an image, you can provide:\n\n        * An :class:`~toga.images.Image` instance; or\n\n        * Any value that would be a valid path specifier when creating a new\n          :class:`~toga.images.Image` instance; or\n\n        * :any:`None` to clear the image view.\n        \"\"\"\n        return self._image\n\n    @image.setter\n    def image(self, image):\n        if isinstance(image, toga.Image):\n            self._image = image\n        elif image is None:\n            self._image = None\n        else:\n            self._image = toga.Image(image)\n\n        self._impl.set_image(self._image)\n        self.refresh()\n\n    def as_image(self, format: type[ImageT] = toga.Image) -> ImageT:\n        \"\"\"Return the image in the specified format.\n\n        :param format: Format to provide. Defaults to :class:`~toga.images.Image`; also\n            supports :any:`PIL.Image.Image` if Pillow is installed.\n        :returns: The image in the specified format.\n        \"\"\"\n        return self.image.as_format(format)\n", "path": "core/src/toga/widgets/imageview.py"}]}