ตำแหน่งของ ไฟล์ต่างๆ 1. ขั้นแรกเราจะเริ่มจากการ import module os กับ pillow
Code: Select all
from PIL import Image
import os
Code: Select all
parth = "images/"
Code: Select all
for i in os.listdir ( parth ):
if i.endswith ( '.jpeg' ):
Code: Select all
f = Image.open(parth + i)
p, p1 = os.path.splitext ( i )
Code: Select all
f.save("Testimg/{}.png".format(p))
Code: Select all
from PIL import Image
import os
parth = "images/"
for i in os.listdir ( parth ):
if i.endswith ( '.jpeg' ):
f = Image.open(parth + i)
p, p1 = os.path.splitext ( i )
f.save("Testimg/{}.png".format(p))
https://pillow.readthedocs.io/en/stable/reference/index.html
https://note.nkmk.me/en/python-pillow-basic/
https://www.pythonforbeginners.com/gui/how-to-use-pillow