Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert files from jpg to png and save in a new directory python

from PIL import Image
import os

directory = r'D:PATH'
c=1
for filename in os.listdir(directory):
    if filename.endswith(".jpg"):
        im = Image.open(filename)
        name='img'+str(c)+'.png'
        rgb_im = im.convert('RGB')
        rgb_im.save(name)
        c+=1
        print(os.path.join(directory, filename))
        continue
    else:
        continue
Comment

save image url to png python

import urllib.request

#python 3
urllib.request.urlretrieve(url, filename)
Comment

PREVIOUS NEXT
Code Example
Python :: python rock paper scissor 
Python :: python format float 
Python :: notify2 python example 
Python :: sort by index pandas 
Python :: python namedtuple 
Python :: previous value list loop python 
Python :: python get all methods of object 
Python :: oppsite of abs() python 
Python :: pandas dataframe get number of columns 
Python :: removing a channel from aconda 
Python :: drop rows with certain values pandas 
Python :: python for doing os command execution 
Python :: neural network import 
Python :: chrome selenium python 
Python :: python make api request 
Python :: return column of matrix numpy 
Python :: show all rows with nan for a column value pandas 
Python :: encoding read_csv 
Python :: python better while loop that count up 
Python :: make csv lowercase python 
Python :: filter list dict 
Python :: convert base64 to image python 
Python :: pythondatetime cheatsheet 
Python :: download files requests python 
Python :: flask post vs get 
Python :: unpack tuple python 
Python :: convert from epoch to utc python 
Python :: source code of Tortoise and hare algorithm in python 
Python :: frequency unique pandas 
Python :: python list subdirectories 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =