【发布时间】:2020-04-05 20:19:30
【问题描述】:
我的目标是随机播放 512x512 Python Pillow 图像中的所有像素。另外,我需要时间表现相对较好。我试过的:
from PIL import Image
import numpy as np
orig = Image.open('img/input2.jpg')
orig_px = orig.getdata()
np_px = np.asarray(orig_px)
np.random.shuffle(np_px)
res = Image.fromarray(np_px.astype('uint8')).convert('RGB')
res.show()
预览应用程序给我以下错误:
无法打开文件“tmp11g28d6z.PNG”。 它可能已损坏或使用了 Preview 无法识别的文件格式。
我不知道出了什么问题。对于修复此代码或尝试不同方法来解决此问题的任何建议,我将不胜感激。
【问题讨论】:
标签: python image python-imaging-library