import Image
Image . open( '1.bmp' ) . save( '1.png' )
import os , Image
os . chdir( 'F: \\ 4habr \\ 1publication' ) # ,
for fname in os . listdir(os . getcwd()): # os.listdir - , -, , ,
try :
Image . open(fname) . save(os . path . splitext(fname) + '.png' ) # os.getcwd() - ,
except DefaultError:
print ( 'Sorry, we have no pictures.' )
Source: https://habr.com/ru/post/102463/