| 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, |