I'm trying to do a simple rotation of a sample image, but when I try to display it, the file just shows black pixels. I can tell that it has rotated, because the dimensions are changed properly.
from io import BytesIO
import numpy as np
from PIL import Image
from skimage.transform import rotate
from flask import send_file
image_file = Image.open(file_path).convert("L")
image_array = np.array(image_file)
image_array_rotated = rotate(image_array, angle=90, resize=True)
rotated_image_file = Image.fromarray(image_array_rotated).convert("L")
buffered_image_file = BytesIO()
rotated_image_file.save(buffered_image_file, 'PNG')
buffered_image_file.seek(0)
return send_file(buffered_image_file, mimetype='image/png')
If I remove the rotation code and show the original image, or the converted grayscale ("L") image, they both show up fine. My rotated image is just black.