Write a Python Program to Find the Size (Resolution) of an Image
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("Collage.jpg")
Output
The resolution of the image is 12343 x 13626
Comments
Post a Comment