【发布时间】:2021-11-20 15:47:36
【问题描述】:
我用来将 BMP 转换为 GIF 的代码
click here to view the image formats
我用来将 BMP 转换为 GIF 的代码
from PIL import Image
import glob
# Create the frames
frames = []
imgs = glob.glob("*.bmp")
for i in imgs:
new_frame = Image.open(i)
frames.append(new_frame)
# Save into a GIF file that loops forever
frames[0].save('bmp_to_gif.gif', format='GIF',
append_images=frames[1:],
save_all=True,
duration=300, loop=0)
BMP 转 PNG
from PIL import Image
Image.open("sample_1920×1280.bmp").save("sample1.png")
【问题讨论】:
-
你从哪里得到 png 应该小于 gif 的概念?这完全取决于源材料。
-
这并不是一个真正的平等比较,生成一个(对我们来说)未知大小的图像与单个图像的动画 GIF。
-
两种情况下得到的颜色深度是否相同?
-
@sj95126 看一下附上的图片,我已经展示了我的 gif 文件及其文件大小。而 gif 只有 1 帧。
-
WIll it work if是您在这里从未问过的问题。做吧,让我们知道结果
标签: python image compression png gif