Tuesday, April 17, 2018

Image Resolution Python

Tags

Practical 8: Write a program to find resolution of JPEG image.

Code :

def jpeg_res(filename):
    with open(filename,'rb') as img_file:

        img_file.seek(163)

        a = img_file.read(2)

        height = (a[0] << 8) + a[1]

        a = img_file.read(2)

        width = (a[0] << 8) + a[1]

    print("The resolution of the image is",width,"x",height)

jpeg_res("image.jpg");
 
 
Output:
 

 


 
Code Thanks :
We thank Programiz for this code 
https://www.programiz.com/python-programming/examples/resolution-image 


Next :
Practical 9 A* Search