Last active
July 30, 2018 07:24
-
-
Save nuriozbey/512e414bc7f24d81a3df2bebd9d7d6f2 to your computer and use it in GitHub Desktop.
png2jpeg - png2jpg -jpeg2png ... ect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Wed July 24 10:55:43 2018 | |
| This script is to convert images | |
| @author: Nuri Özbey | |
| Email: [email protected] | |
| """ | |
| from PIL import Image | |
| import glob | |
| print("IMAGE CONVERTER ©nuribey ") | |
| imputtype = "png" | |
| inputtype = input("ENTER THE INPUT FileType : ") | |
| outtype = "JPEG" | |
| outtype = input("ENTER THE OUTPUT FileType : ") | |
| inputpath = input("ENTER THE İNPUT PATH : ")#C:/?/?/Images/003 | |
| outpath = input("ENTER THE OUTPUT PATH : ")#C:/?/Images/004 | |
| outfilename = "" | |
| outfilename = input("ENTER THE File Name Prefix : ") | |
| print("Entered in Path: "+ inputpath) | |
| print("Entered in Type: "+ inputtype) | |
| print("Entered out Path: "+ outpath) | |
| print("Entered out Type: "+ outtype) | |
| #image_list = [] | |
| i = 1 | |
| for filename in glob.glob(inputpath+'/*.'+inputtype): #assuming gif | |
| im=Image.open(filename) | |
| if i<10: | |
| dest = outpath+'/'+outfilename+'00'+str(i)+'.'+outtype | |
| elif i<100: | |
| dest = outpath+'/'+outfilename+'0'+str(i)+'.'+outtype | |
| else: | |
| dest = outpath+'/'+outfilename+'' +str(i) + '.'+outtype | |
| im.convert('RGB').save(dest, outtype) # this converts png image as jpeg | |
| i = i+1 | |
| print("Image "+dest+" saved..!") | |
| #image_list.append(im) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment