Skip to content

elibooklover/ConvertingPhotos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Converting Image File Formats

Converting all files (.jpg to .png) with Python by Hoyeol Kim

Converting a Single File

If you want to simply covert a single file (.jpg to .png), use the following code from SingleFile.py:

from PIL import Image

im = Image.open('photo.jpg')
im.save('photo.png')

Converting Multiple Files

If you want to covert multiple files in a directory, use the following code from MultipleFiles.py:

from PIL import Image
import os
directory = r'your directory'
for filename in os.listdir(directory):
    if filename.endswith(".jpg"):
        prefix = filename.split(".jpg")[0]
        im = Image.open(filename)
        im.save(prefix+'.png')
    else:
        continue

About

Converting all files (.jpg to .png) with Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages