如何使用 Python PIL 将图像保存到特定目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31434278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:00:02  来源:igfitidea点击:

How do I use Python PIL to save an image to a particular directory?

pythonimagedirectorysave

提问by Troll_Hunter

For example I want to manipulate some image and then save it to a particular directory. How do I save to a specific directory other than the one I am in? I understand that this will save to the directory I am in:

例如,我想操作一些图像,然后将其保存到特定目录。如何保存到我所在目录以外的特定目录?我知道这将保存到我所在的目录中:

from PIL import Image
""" Some Code """
img.save("sample.png", "")

How do i save to a different driectory?

我如何保存到不同的文件夹?

采纳答案by itzMEonTV

Try this

尝试这个

img.save('/absolute/path/to/myphoto.jpg', 'JPEG')