from PIL import Image
image = Image.open("image.jpg")
file_path = io.BytesIO();
image.save(file_path,'JPEG');
image2 = Image.open(file_path.getvalue());
Run Code Online (Sandbox Code Playgroud)
我在运行程序TypeError: embedded NUL character
的最后一条语句中收到此错误Image.open
从流中打开文件的正确方法是什么?
我想存储与原始图像完全相同的图像,而不改变质量,
当我quality=100
在 Pillow Python 中设置时,保存的图像比原始图像少 5kB空间
如何保留尺寸?我正在从流中检索图像
from PIL import Image, ImageFilter
image = Image.open("image.jpg")
file_path = io.BytesIO();
image.save(file_path,'JPEG',quality=100);
file_path.seek(0);
image2 = Image.open(file_path)
image2.save("image_copy2.jpg",'JPEG');
Run Code Online (Sandbox Code Playgroud)