Resize file data image .PNG in Python -


import image import os   def resize_file(fname):     width, height = get_image_size(fname) /// get_image_size return width , 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') 

* problem : line when change ext2 = ".png" data file not change. when ext2 = ".jpg" data size down (case true). want change image.png data file size down , result still image.png !

close !

a lossless format, such png, allows 1 recover exact pixel values of original image compressed file. lossy format makes assumptions human eye can , can't see, , removes "non relevant" information reduce size of file. way, have image visually indistinguishable original - until zoom , find artifacts.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -