Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Merge remote-tracking branch 'upstream/master' into 3689-update

drs-1135e2d256894f
diff --cc scrapy/pipelines/images.py
index 09194a0fe,aafd1d8b2..d3254bc20
--- a/scrapy/pipelines/images.py
+++ b/scrapy/pipelines/images.py
@@@ -128,20 -125,11 +128,21 @@@ class ImagesPipeline(FilesPipeline)
width, height = orig_image.size
if width < self.min_width or height < self.min_height:
- raise ImageException("Image too small (%dx%d < %dx%d)" %
- (width, height, self.min_width, self.min_height))
+ raise ImageException("Image too small "
+ f"({width}x{height} < "
+ f"{self.min_width}x{self.min_height})")
- image, buf = self.convert_image(orig_image)
+ if self._deprecated_convert_image is None:
+ self._deprecated_convert_image = 'response_body' not in get_func_args(self.convert_image)
+ if self._deprecated_convert_image:
+ warnings.warn('ImagesPipeline.convert_image() method overriden in a deprecated way, '
+ 'overriden method does not accept response_body argument.',
+ category=ScrapyDeprecationWarning)
+
+ if self._deprecated_convert_image:
+ image, buf = self.convert_image(orig_image)
+ else:
+ image, buf = self.convert_image(orig_image, response_body=BytesIO(response.body))
yield path, image, buf
for thumb_id, size in self.thumbs.items():