I'm trying to check if an image has a maximum resolution of 16 megapixels or not. Here is my code:
from PIL import Image
im = Image.open("image.jpg")
width, height = im.size
resolution = width * height
if resolution > (16 * 1000000):
print("Image has a resolution greater than 16 megapixels.")
else:
print("Image has a resolution less than or equal to 16 megapixels.")
But I'm not sure if this is working as I don't know what megapixels represent.
source https://stackoverflow.com/questions/75086505/check-if-images-resolution-is-more-than-16-megapixels-in-python
Comments
Post a Comment