如何删除PIL图像?

时间:2022-08-13 00:24:04

I am trying to replace an Image file using Python PIL.

我正在尝试使用Python PIL替换Image文件。

im = Image.open(logo_dir+cat_string_im)

What function do I call to delete the original file?

我打电话删除原始文件的功能是什么?

im.delete() or im.replace() don't work.

im.delete()或im.replace()不起作用。

2 个解决方案

#1


5  

Probably the most straightforward way is to use os.remove() to delete the file. This is basic functionality, so it's not too likely that every module that works with files also includes facilities for file copying, moving, deletion, etc.

可能最直接的方法是使用os.remove()删除文件。这是基本功能,因此使用文件的每个模块都不太可能包含文件复制,移动,删除等功能。

#2


3  

You don't need PIL to delete the image. You can do it with

您不需要PIL来删除图像。你可以做到

os.remove(path, *, dir_fd=None)

http://docs.python.org/3.3/library/os.html#os.remove

http://docs.python.org/3.3/library/os.html#os.remove

#1


5  

Probably the most straightforward way is to use os.remove() to delete the file. This is basic functionality, so it's not too likely that every module that works with files also includes facilities for file copying, moving, deletion, etc.

可能最直接的方法是使用os.remove()删除文件。这是基本功能,因此使用文件的每个模块都不太可能包含文件复制,移动,删除等功能。

#2


3  

You don't need PIL to delete the image. You can do it with

您不需要PIL来删除图像。你可以做到

os.remove(path, *, dir_fd=None)

http://docs.python.org/3.3/library/os.html#os.remove

http://docs.python.org/3.3/library/os.html#os.remove