MCPcopy
hub / github.com/scrapy/scrapy / get_images

Method get_images

scrapy/pipelines/images.py:155–185  ·  view source on GitHub ↗
(
        self,
        response: Response,
        request: Request,
        info: MediaPipeline.SpiderInfo,
        *,
        item: Any = None,
    )

Source from the content-addressed store, hash-verified

153 return checksum
154
155 def get_images(
156 self,
157 response: Response,
158 request: Request,
159 info: MediaPipeline.SpiderInfo,
160 *,
161 item: Any = None,
162 ) -> Iterable[tuple[str, Image.Image, BytesIO]]:
163 path = self.file_path(request, response=response, info=info, item=item)
164 orig_image = self._Image.open(BytesIO(response.body))
165 transposed_image = self._ImageOps.exif_transpose(orig_image)
166
167 width, height = transposed_image.size
168 if width < self.min_width or height < self.min_height:
169 raise ImageException(
170 "Image too small "
171 f"({width}x{height} < "
172 f"{self.min_width}x{self.min_height})"
173 )
174
175 image, buf = self.convert_image(
176 transposed_image, response_body=BytesIO(response.body)
177 )
178 yield path, image, buf
179
180 for thumb_id, size in self.thumbs.items():
181 thumb_path = self.thumb_path(
182 request, thumb_id, response=response, info=info, item=item
183 )
184 thumb_image, thumb_buf = self.convert_image(image, size, response_body=buf)
185 yield thumb_path, thumb_image, thumb_buf
186
187 def convert_image(
188 self,

Callers 4

image_downloadedMethod · 0.95
test_get_imagesMethod · 0.80

Calls 6

file_pathMethod · 0.95
convert_imageMethod · 0.95
thumb_pathMethod · 0.95
ImageExceptionClass · 0.85
itemsMethod · 0.80
openMethod · 0.45

Tested by 3

test_get_imagesMethod · 0.64