import Image
import os
def resize_file(fname):
width, height = get_image_size(fname) /// get_image_size return width and height ///
name, ext = os.path.splitext(fname)
new_image_file = "%s%s%s" %(name, 'new' , ext)
im1 = Image.open(fname)
im5 = im1.resize((width, height), Image.ANTIALIAS)
ext2 = ".jpg"
im5.save(name + 'new' + ext2)
import webbrowser
webbrowser.open(name + 'new' + ext2)
if __name__ == "__main__":
resize_file('/home/kirito/Desktop/HD_69830_Planet.jpg')
resize_file('/home/kirito/Desktop/cod2.png')
* My problem : line when I change ext2 = ".png" data file not change. but when ext2 = ".jpg" data size down (case true). I want change image.png data file size down and result still image.png !