We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
DeprecationWarning: ANTIALIAS is deprecated
> scrapy/pipelines/images.py:163: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
>    image.thumbnail(size, self._Image.ANTIALIAS)

This is deprecated since Pillow 9.1.0, released in April. We should check if `Resampling.LANCZOS` is already available in the earliest version we support (7.1.0 as far as I can see), and use it if it's available there. If it was added later, I think we need to decide how to proceed.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scrapy/pipelines/images.py`
Content:
```
1 """
2 Images Pipeline
3 
4 See documentation in topics/media-pipeline.rst
5 """
6 import functools
7 import hashlib
8 from contextlib import suppress
9 from io import BytesIO
10 
11 from itemadapter import ItemAdapter
12 
13 from scrapy.exceptions import DropItem, NotConfigured
14 from scrapy.http import Request
15 from scrapy.pipelines.files import FileException, FilesPipeline
16 # TODO: from scrapy.pipelines.media import MediaPipeline
17 from scrapy.settings import Settings
18 from scrapy.utils.misc import md5sum
19 from scrapy.utils.python import to_bytes
20 
21 
22 class NoimagesDrop(DropItem):
23     """Product with no images exception"""
24 
25 
26 class ImageException(FileException):
27     """General image error exception"""
28 
29 
30 class ImagesPipeline(FilesPipeline):
31     """Abstract pipeline that implement the image thumbnail generation logic
32 
33     """
34 
35     MEDIA_NAME = 'image'
36 
37     # Uppercase attributes kept for backward compatibility with code that subclasses
38     # ImagesPipeline. They may be overridden by settings.
39     MIN_WIDTH = 0
40     MIN_HEIGHT = 0
41     EXPIRES = 90
42     THUMBS = {}
43     DEFAULT_IMAGES_URLS_FIELD = 'image_urls'
44     DEFAULT_IMAGES_RESULT_FIELD = 'images'
45 
46     def __init__(self, store_uri, download_func=None, settings=None):
47         try:
48             from PIL import Image
49             self._Image = Image
50         except ImportError:
51             raise NotConfigured(
52                 'ImagesPipeline requires installing Pillow 4.0.0 or later'
53             )
54 
55         super().__init__(store_uri, settings=settings, download_func=download_func)
56 
57         if isinstance(settings, dict) or settings is None:
58             settings = Settings(settings)
59 
60         resolve = functools.partial(self._key_for_pipe,
61                                     base_class_name="ImagesPipeline",
62                                     settings=settings)
63         self.expires = settings.getint(
64             resolve("IMAGES_EXPIRES"), self.EXPIRES
65         )
66 
67         if not hasattr(self, "IMAGES_RESULT_FIELD"):
68             self.IMAGES_RESULT_FIELD = self.DEFAULT_IMAGES_RESULT_FIELD
69         if not hasattr(self, "IMAGES_URLS_FIELD"):
70             self.IMAGES_URLS_FIELD = self.DEFAULT_IMAGES_URLS_FIELD
71 
72         self.images_urls_field = settings.get(
73             resolve('IMAGES_URLS_FIELD'),
74             self.IMAGES_URLS_FIELD
75         )
76         self.images_result_field = settings.get(
77             resolve('IMAGES_RESULT_FIELD'),
78             self.IMAGES_RESULT_FIELD
79         )
80         self.min_width = settings.getint(
81             resolve('IMAGES_MIN_WIDTH'), self.MIN_WIDTH
82         )
83         self.min_height = settings.getint(
84             resolve('IMAGES_MIN_HEIGHT'), self.MIN_HEIGHT
85         )
86         self.thumbs = settings.get(
87             resolve('IMAGES_THUMBS'), self.THUMBS
88         )
89 
90     @classmethod
91     def from_settings(cls, settings):
92         s3store = cls.STORE_SCHEMES['s3']
93         s3store.AWS_ACCESS_KEY_ID = settings['AWS_ACCESS_KEY_ID']
94         s3store.AWS_SECRET_ACCESS_KEY = settings['AWS_SECRET_ACCESS_KEY']
95         s3store.AWS_SESSION_TOKEN = settings['AWS_SESSION_TOKEN']
96         s3store.AWS_ENDPOINT_URL = settings['AWS_ENDPOINT_URL']
97         s3store.AWS_REGION_NAME = settings['AWS_REGION_NAME']
98         s3store.AWS_USE_SSL = settings['AWS_USE_SSL']
99         s3store.AWS_VERIFY = settings['AWS_VERIFY']
100         s3store.POLICY = settings['IMAGES_STORE_S3_ACL']
101 
102         gcs_store = cls.STORE_SCHEMES['gs']
103         gcs_store.GCS_PROJECT_ID = settings['GCS_PROJECT_ID']
104         gcs_store.POLICY = settings['IMAGES_STORE_GCS_ACL'] or None
105 
106         ftp_store = cls.STORE_SCHEMES['ftp']
107         ftp_store.FTP_USERNAME = settings['FTP_USER']
108         ftp_store.FTP_PASSWORD = settings['FTP_PASSWORD']
109         ftp_store.USE_ACTIVE_MODE = settings.getbool('FEED_STORAGE_FTP_ACTIVE')
110 
111         store_uri = settings['IMAGES_STORE']
112         return cls(store_uri, settings=settings)
113 
114     def file_downloaded(self, response, request, info, *, item=None):
115         return self.image_downloaded(response, request, info, item=item)
116 
117     def image_downloaded(self, response, request, info, *, item=None):
118         checksum = None
119         for path, image, buf in self.get_images(response, request, info, item=item):
120             if checksum is None:
121                 buf.seek(0)
122                 checksum = md5sum(buf)
123             width, height = image.size
124             self.store.persist_file(
125                 path, buf, info,
126                 meta={'width': width, 'height': height},
127                 headers={'Content-Type': 'image/jpeg'})
128         return checksum
129 
130     def get_images(self, response, request, info, *, item=None):
131         path = self.file_path(request, response=response, info=info, item=item)
132         orig_image = self._Image.open(BytesIO(response.body))
133 
134         width, height = orig_image.size
135         if width < self.min_width or height < self.min_height:
136             raise ImageException("Image too small "
137                                  f"({width}x{height} < "
138                                  f"{self.min_width}x{self.min_height})")
139 
140         image, buf = self.convert_image(orig_image)
141         yield path, image, buf
142 
143         for thumb_id, size in self.thumbs.items():
144             thumb_path = self.thumb_path(request, thumb_id, response=response, info=info, item=item)
145             thumb_image, thumb_buf = self.convert_image(image, size)
146             yield thumb_path, thumb_image, thumb_buf
147 
148     def convert_image(self, image, size=None):
149         if image.format == 'PNG' and image.mode == 'RGBA':
150             background = self._Image.new('RGBA', image.size, (255, 255, 255))
151             background.paste(image, image)
152             image = background.convert('RGB')
153         elif image.mode == 'P':
154             image = image.convert("RGBA")
155             background = self._Image.new('RGBA', image.size, (255, 255, 255))
156             background.paste(image, image)
157             image = background.convert('RGB')
158         elif image.mode != 'RGB':
159             image = image.convert('RGB')
160 
161         if size:
162             image = image.copy()
163             image.thumbnail(size, self._Image.ANTIALIAS)
164 
165         buf = BytesIO()
166         image.save(buf, 'JPEG')
167         return image, buf
168 
169     def get_media_requests(self, item, info):
170         urls = ItemAdapter(item).get(self.images_urls_field, [])
171         return [Request(u) for u in urls]
172 
173     def item_completed(self, results, item, info):
174         with suppress(KeyError):
175             ItemAdapter(item)[self.images_result_field] = [x for ok, x in results if ok]
176         return item
177 
178     def file_path(self, request, response=None, info=None, *, item=None):
179         image_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()
180         return f'full/{image_guid}.jpg'
181 
182     def thumb_path(self, request, thumb_id, response=None, info=None, *, item=None):
183         thumb_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()
184         return f'thumbs/{thumb_id}/{thumb_guid}.jpg'
185
```
--- 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/scrapy/pipelines/images.py b/scrapy/pipelines/images.py
--- a/scrapy/pipelines/images.py
+++ b/scrapy/pipelines/images.py
@@ -160,7 +160,14 @@
 
         if size:
             image = image.copy()
-            image.thumbnail(size, self._Image.ANTIALIAS)
+            try:
+                # Image.Resampling.LANCZOS was added in Pillow 9.1.0
+                # remove this try except block,
+                # when updating the minimum requirements for Pillow.
+                resampling_filter = self._Image.Resampling.LANCZOS
+            except AttributeError:
+                resampling_filter = self._Image.ANTIALIAS
+            image.thumbnail(size, resampling_filter)
 
         buf = BytesIO()
         image.save(buf, 'JPEG')

{"golden_diff": "diff --git a/scrapy/pipelines/images.py b/scrapy/pipelines/images.py\n--- a/scrapy/pipelines/images.py\n+++ b/scrapy/pipelines/images.py\n@@ -160,7 +160,14 @@\n \n         if size:\n             image = image.copy()\n-            image.thumbnail(size, self._Image.ANTIALIAS)\n+            try:\n+                # Image.Resampling.LANCZOS was added in Pillow 9.1.0\n+                # remove this try except block,\n+                # when updating the minimum requirements for Pillow.\n+                resampling_filter = self._Image.Resampling.LANCZOS\n+            except AttributeError:\n+                resampling_filter = self._Image.ANTIALIAS\n+            image.thumbnail(size, resampling_filter)\n \n         buf = BytesIO()\n         image.save(buf, 'JPEG')\n", "issue": "DeprecationWarning: ANTIALIAS is deprecated\n> scrapy/pipelines/images.py:163: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.\r\n>    image.thumbnail(size, self._Image.ANTIALIAS)\r\n\r\nThis is deprecated since Pillow 9.1.0, released in April. We should check if `Resampling.LANCZOS` is already available in the earliest version we support (7.1.0 as far as I can see), and use it if it's available there. If it was added later, I think we need to decide how to proceed.\n", "before_files": [{"content": "\"\"\"\nImages Pipeline\n\nSee documentation in topics/media-pipeline.rst\n\"\"\"\nimport functools\nimport hashlib\nfrom contextlib import suppress\nfrom io import BytesIO\n\nfrom itemadapter import ItemAdapter\n\nfrom scrapy.exceptions import DropItem, NotConfigured\nfrom scrapy.http import Request\nfrom scrapy.pipelines.files import FileException, FilesPipeline\n# TODO: from scrapy.pipelines.media import MediaPipeline\nfrom scrapy.settings import Settings\nfrom scrapy.utils.misc import md5sum\nfrom scrapy.utils.python import to_bytes\n\n\nclass NoimagesDrop(DropItem):\n    \"\"\"Product with no images exception\"\"\"\n\n\nclass ImageException(FileException):\n    \"\"\"General image error exception\"\"\"\n\n\nclass ImagesPipeline(FilesPipeline):\n    \"\"\"Abstract pipeline that implement the image thumbnail generation logic\n\n    \"\"\"\n\n    MEDIA_NAME = 'image'\n\n    # Uppercase attributes kept for backward compatibility with code that subclasses\n    # ImagesPipeline. They may be overridden by settings.\n    MIN_WIDTH = 0\n    MIN_HEIGHT = 0\n    EXPIRES = 90\n    THUMBS = {}\n    DEFAULT_IMAGES_URLS_FIELD = 'image_urls'\n    DEFAULT_IMAGES_RESULT_FIELD = 'images'\n\n    def __init__(self, store_uri, download_func=None, settings=None):\n        try:\n            from PIL import Image\n            self._Image = Image\n        except ImportError:\n            raise NotConfigured(\n                'ImagesPipeline requires installing Pillow 4.0.0 or later'\n            )\n\n        super().__init__(store_uri, settings=settings, download_func=download_func)\n\n        if isinstance(settings, dict) or settings is None:\n            settings = Settings(settings)\n\n        resolve = functools.partial(self._key_for_pipe,\n                                    base_class_name=\"ImagesPipeline\",\n                                    settings=settings)\n        self.expires = settings.getint(\n            resolve(\"IMAGES_EXPIRES\"), self.EXPIRES\n        )\n\n        if not hasattr(self, \"IMAGES_RESULT_FIELD\"):\n            self.IMAGES_RESULT_FIELD = self.DEFAULT_IMAGES_RESULT_FIELD\n        if not hasattr(self, \"IMAGES_URLS_FIELD\"):\n            self.IMAGES_URLS_FIELD = self.DEFAULT_IMAGES_URLS_FIELD\n\n        self.images_urls_field = settings.get(\n            resolve('IMAGES_URLS_FIELD'),\n            self.IMAGES_URLS_FIELD\n        )\n        self.images_result_field = settings.get(\n            resolve('IMAGES_RESULT_FIELD'),\n            self.IMAGES_RESULT_FIELD\n        )\n        self.min_width = settings.getint(\n            resolve('IMAGES_MIN_WIDTH'), self.MIN_WIDTH\n        )\n        self.min_height = settings.getint(\n            resolve('IMAGES_MIN_HEIGHT'), self.MIN_HEIGHT\n        )\n        self.thumbs = settings.get(\n            resolve('IMAGES_THUMBS'), self.THUMBS\n        )\n\n    @classmethod\n    def from_settings(cls, settings):\n        s3store = cls.STORE_SCHEMES['s3']\n        s3store.AWS_ACCESS_KEY_ID = settings['AWS_ACCESS_KEY_ID']\n        s3store.AWS_SECRET_ACCESS_KEY = settings['AWS_SECRET_ACCESS_KEY']\n        s3store.AWS_SESSION_TOKEN = settings['AWS_SESSION_TOKEN']\n        s3store.AWS_ENDPOINT_URL = settings['AWS_ENDPOINT_URL']\n        s3store.AWS_REGION_NAME = settings['AWS_REGION_NAME']\n        s3store.AWS_USE_SSL = settings['AWS_USE_SSL']\n        s3store.AWS_VERIFY = settings['AWS_VERIFY']\n        s3store.POLICY = settings['IMAGES_STORE_S3_ACL']\n\n        gcs_store = cls.STORE_SCHEMES['gs']\n        gcs_store.GCS_PROJECT_ID = settings['GCS_PROJECT_ID']\n        gcs_store.POLICY = settings['IMAGES_STORE_GCS_ACL'] or None\n\n        ftp_store = cls.STORE_SCHEMES['ftp']\n        ftp_store.FTP_USERNAME = settings['FTP_USER']\n        ftp_store.FTP_PASSWORD = settings['FTP_PASSWORD']\n        ftp_store.USE_ACTIVE_MODE = settings.getbool('FEED_STORAGE_FTP_ACTIVE')\n\n        store_uri = settings['IMAGES_STORE']\n        return cls(store_uri, settings=settings)\n\n    def file_downloaded(self, response, request, info, *, item=None):\n        return self.image_downloaded(response, request, info, item=item)\n\n    def image_downloaded(self, response, request, info, *, item=None):\n        checksum = None\n        for path, image, buf in self.get_images(response, request, info, item=item):\n            if checksum is None:\n                buf.seek(0)\n                checksum = md5sum(buf)\n            width, height = image.size\n            self.store.persist_file(\n                path, buf, info,\n                meta={'width': width, 'height': height},\n                headers={'Content-Type': 'image/jpeg'})\n        return checksum\n\n    def get_images(self, response, request, info, *, item=None):\n        path = self.file_path(request, response=response, info=info, item=item)\n        orig_image = self._Image.open(BytesIO(response.body))\n\n        width, height = orig_image.size\n        if width < self.min_width or height < self.min_height:\n            raise ImageException(\"Image too small \"\n                                 f\"({width}x{height} < \"\n                                 f\"{self.min_width}x{self.min_height})\")\n\n        image, buf = self.convert_image(orig_image)\n        yield path, image, buf\n\n        for thumb_id, size in self.thumbs.items():\n            thumb_path = self.thumb_path(request, thumb_id, response=response, info=info, item=item)\n            thumb_image, thumb_buf = self.convert_image(image, size)\n            yield thumb_path, thumb_image, thumb_buf\n\n    def convert_image(self, image, size=None):\n        if image.format == 'PNG' and image.mode == 'RGBA':\n            background = self._Image.new('RGBA', image.size, (255, 255, 255))\n            background.paste(image, image)\n            image = background.convert('RGB')\n        elif image.mode == 'P':\n            image = image.convert(\"RGBA\")\n            background = self._Image.new('RGBA', image.size, (255, 255, 255))\n            background.paste(image, image)\n            image = background.convert('RGB')\n        elif image.mode != 'RGB':\n            image = image.convert('RGB')\n\n        if size:\n            image = image.copy()\n            image.thumbnail(size, self._Image.ANTIALIAS)\n\n        buf = BytesIO()\n        image.save(buf, 'JPEG')\n        return image, buf\n\n    def get_media_requests(self, item, info):\n        urls = ItemAdapter(item).get(self.images_urls_field, [])\n        return [Request(u) for u in urls]\n\n    def item_completed(self, results, item, info):\n        with suppress(KeyError):\n            ItemAdapter(item)[self.images_result_field] = [x for ok, x in results if ok]\n        return item\n\n    def file_path(self, request, response=None, info=None, *, item=None):\n        image_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()\n        return f'full/{image_guid}.jpg'\n\n    def thumb_path(self, request, thumb_id, response=None, info=None, *, item=None):\n        thumb_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()\n        return f'thumbs/{thumb_id}/{thumb_guid}.jpg'\n", "path": "scrapy/pipelines/images.py"}], "after_files": [{"content": "\"\"\"\nImages Pipeline\n\nSee documentation in topics/media-pipeline.rst\n\"\"\"\nimport functools\nimport hashlib\nfrom contextlib import suppress\nfrom io import BytesIO\n\nfrom itemadapter import ItemAdapter\n\nfrom scrapy.exceptions import DropItem, NotConfigured\nfrom scrapy.http import Request\nfrom scrapy.pipelines.files import FileException, FilesPipeline\n# TODO: from scrapy.pipelines.media import MediaPipeline\nfrom scrapy.settings import Settings\nfrom scrapy.utils.misc import md5sum\nfrom scrapy.utils.python import to_bytes\n\n\nclass NoimagesDrop(DropItem):\n    \"\"\"Product with no images exception\"\"\"\n\n\nclass ImageException(FileException):\n    \"\"\"General image error exception\"\"\"\n\n\nclass ImagesPipeline(FilesPipeline):\n    \"\"\"Abstract pipeline that implement the image thumbnail generation logic\n\n    \"\"\"\n\n    MEDIA_NAME = 'image'\n\n    # Uppercase attributes kept for backward compatibility with code that subclasses\n    # ImagesPipeline. They may be overridden by settings.\n    MIN_WIDTH = 0\n    MIN_HEIGHT = 0\n    EXPIRES = 90\n    THUMBS = {}\n    DEFAULT_IMAGES_URLS_FIELD = 'image_urls'\n    DEFAULT_IMAGES_RESULT_FIELD = 'images'\n\n    def __init__(self, store_uri, download_func=None, settings=None):\n        try:\n            from PIL import Image\n            self._Image = Image\n        except ImportError:\n            raise NotConfigured(\n                'ImagesPipeline requires installing Pillow 4.0.0 or later'\n            )\n\n        super().__init__(store_uri, settings=settings, download_func=download_func)\n\n        if isinstance(settings, dict) or settings is None:\n            settings = Settings(settings)\n\n        resolve = functools.partial(self._key_for_pipe,\n                                    base_class_name=\"ImagesPipeline\",\n                                    settings=settings)\n        self.expires = settings.getint(\n            resolve(\"IMAGES_EXPIRES\"), self.EXPIRES\n        )\n\n        if not hasattr(self, \"IMAGES_RESULT_FIELD\"):\n            self.IMAGES_RESULT_FIELD = self.DEFAULT_IMAGES_RESULT_FIELD\n        if not hasattr(self, \"IMAGES_URLS_FIELD\"):\n            self.IMAGES_URLS_FIELD = self.DEFAULT_IMAGES_URLS_FIELD\n\n        self.images_urls_field = settings.get(\n            resolve('IMAGES_URLS_FIELD'),\n            self.IMAGES_URLS_FIELD\n        )\n        self.images_result_field = settings.get(\n            resolve('IMAGES_RESULT_FIELD'),\n            self.IMAGES_RESULT_FIELD\n        )\n        self.min_width = settings.getint(\n            resolve('IMAGES_MIN_WIDTH'), self.MIN_WIDTH\n        )\n        self.min_height = settings.getint(\n            resolve('IMAGES_MIN_HEIGHT'), self.MIN_HEIGHT\n        )\n        self.thumbs = settings.get(\n            resolve('IMAGES_THUMBS'), self.THUMBS\n        )\n\n    @classmethod\n    def from_settings(cls, settings):\n        s3store = cls.STORE_SCHEMES['s3']\n        s3store.AWS_ACCESS_KEY_ID = settings['AWS_ACCESS_KEY_ID']\n        s3store.AWS_SECRET_ACCESS_KEY = settings['AWS_SECRET_ACCESS_KEY']\n        s3store.AWS_SESSION_TOKEN = settings['AWS_SESSION_TOKEN']\n        s3store.AWS_ENDPOINT_URL = settings['AWS_ENDPOINT_URL']\n        s3store.AWS_REGION_NAME = settings['AWS_REGION_NAME']\n        s3store.AWS_USE_SSL = settings['AWS_USE_SSL']\n        s3store.AWS_VERIFY = settings['AWS_VERIFY']\n        s3store.POLICY = settings['IMAGES_STORE_S3_ACL']\n\n        gcs_store = cls.STORE_SCHEMES['gs']\n        gcs_store.GCS_PROJECT_ID = settings['GCS_PROJECT_ID']\n        gcs_store.POLICY = settings['IMAGES_STORE_GCS_ACL'] or None\n\n        ftp_store = cls.STORE_SCHEMES['ftp']\n        ftp_store.FTP_USERNAME = settings['FTP_USER']\n        ftp_store.FTP_PASSWORD = settings['FTP_PASSWORD']\n        ftp_store.USE_ACTIVE_MODE = settings.getbool('FEED_STORAGE_FTP_ACTIVE')\n\n        store_uri = settings['IMAGES_STORE']\n        return cls(store_uri, settings=settings)\n\n    def file_downloaded(self, response, request, info, *, item=None):\n        return self.image_downloaded(response, request, info, item=item)\n\n    def image_downloaded(self, response, request, info, *, item=None):\n        checksum = None\n        for path, image, buf in self.get_images(response, request, info, item=item):\n            if checksum is None:\n                buf.seek(0)\n                checksum = md5sum(buf)\n            width, height = image.size\n            self.store.persist_file(\n                path, buf, info,\n                meta={'width': width, 'height': height},\n                headers={'Content-Type': 'image/jpeg'})\n        return checksum\n\n    def get_images(self, response, request, info, *, item=None):\n        path = self.file_path(request, response=response, info=info, item=item)\n        orig_image = self._Image.open(BytesIO(response.body))\n\n        width, height = orig_image.size\n        if width < self.min_width or height < self.min_height:\n            raise ImageException(\"Image too small \"\n                                 f\"({width}x{height} < \"\n                                 f\"{self.min_width}x{self.min_height})\")\n\n        image, buf = self.convert_image(orig_image)\n        yield path, image, buf\n\n        for thumb_id, size in self.thumbs.items():\n            thumb_path = self.thumb_path(request, thumb_id, response=response, info=info, item=item)\n            thumb_image, thumb_buf = self.convert_image(image, size)\n            yield thumb_path, thumb_image, thumb_buf\n\n    def convert_image(self, image, size=None):\n        if image.format == 'PNG' and image.mode == 'RGBA':\n            background = self._Image.new('RGBA', image.size, (255, 255, 255))\n            background.paste(image, image)\n            image = background.convert('RGB')\n        elif image.mode == 'P':\n            image = image.convert(\"RGBA\")\n            background = self._Image.new('RGBA', image.size, (255, 255, 255))\n            background.paste(image, image)\n            image = background.convert('RGB')\n        elif image.mode != 'RGB':\n            image = image.convert('RGB')\n\n        if size:\n            image = image.copy()\n            try:\n                # Image.Resampling.LANCZOS was added in Pillow 9.1.0\n                # remove this try except block,\n                # when updating the minimum requirements for Pillow.\n                resampling_filter = self._Image.Resampling.LANCZOS\n            except AttributeError:\n                resampling_filter = self._Image.ANTIALIAS\n            image.thumbnail(size, resampling_filter)\n\n        buf = BytesIO()\n        image.save(buf, 'JPEG')\n        return image, buf\n\n    def get_media_requests(self, item, info):\n        urls = ItemAdapter(item).get(self.images_urls_field, [])\n        return [Request(u) for u in urls]\n\n    def item_completed(self, results, item, info):\n        with suppress(KeyError):\n            ItemAdapter(item)[self.images_result_field] = [x for ok, x in results if ok]\n        return item\n\n    def file_path(self, request, response=None, info=None, *, item=None):\n        image_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()\n        return f'full/{image_guid}.jpg'\n\n    def thumb_path(self, request, thumb_id, response=None, info=None, *, item=None):\n        thumb_guid = hashlib.sha1(to_bytes(request.url)).hexdigest()\n        return f'thumbs/{thumb_id}/{thumb_guid}.jpg'\n", "path": "scrapy/pipelines/images.py"}]}