Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
if self.image_data is None:
raise RuntimeError('No image data, please be sure that ``sync_image_data`` is set to True')
x = int(x)
y = int(y)
if width is None:
width = self.width - x
if height is None:
height = self.height - y
width = int(width)
height = int(height)
image_data = image_bytes_to_array(self.image_data)
return image_data[y:y + height, x:x + width]