1

I have a list of images names which are associated with real resources in file system. For example:

'image1.png'
'image2.jpg'
'image3.jpeg'

I have to conver all of them into png with the same name. How can I do that in python?

The ideas are: using PIL or ImageMagic.

1 Answer 1

3
from PIL import Image
import os
for filename in filelist:
    basename, ext = os.path.splitext(filename)
    if ext.lower() == ".png":
        continue
    img = Image.open(filename)
    img.save(basename + ".png")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.