It is hard to explain so please look at the image. It appears to rotate the data within the image but not the image itself.
original:
Rotated -90:
block = scene.read_block()
image = PILImage.fromarray(block)
image_rotate = image.rotate(-90)
buf = BytesIO()
image_rotate.save(buf, "JPEG", quality=90)
return buf.getvalue()
The viewport didn't rotate only the image inside.
Thanks
you need to use expand=True to change the size
image.rotate(-90, expand=True)
it is in the documentation