我正在运行一个代码,它使用im.convert("RGB")
将图像转换为RGB格式。但是,当我运行这个程序时,它会打印在终端UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images
中,虽然它没有停止程序,但是每次都会弹出,很烦人。有办法移除这个吗?
发布于 2022-04-12 10:37:08
将图像转换为RGBA
for image in os.listdir(path/to/img/dir):
im = Image.open(image)
# If is png image
if im.format is 'PNG':
# and is not RGBA
if im.mode is not 'RGBA':
im.convert("RGBA").save(f"{image}2.png")
https://stackoverflow.com/questions/70839890
复制相似问题