Home > Net >  Information about image
Information about image

Time:09-21

How can I get the information about image? I need file size (bytes), image size (pixels), color mode, bits per pixel. I've already found image size (pixels) but I can't find another.

I have:

from skimage.io import imread

im = imread('abc.png')
print("Size: ", im.size, im.shape)

CodePudding user response:

I recommend using the Pillow library.

This will give you all the requested information about the image except the file size.

from PIL import Image

im = Image.open('whatever.png')
width, height = im.size

Refer to this link for the attributes for the image object

In order to get the file size use this snippet below.

import os
print os.stat('somefile.ext').st_size
  • Related