如何在不改变质量的前提下保存简单的图片?

2024-10-06 11:17:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我想保存一张与原稿完全相同的图像,而不改变质量

当我在PillowPython中设置quality=100时,保存的图像比原始图像少了5kB空间

如何保持尺寸?我正在从streams检索图像

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');

Tags: path图像imagesave质量空间openfile