Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can I calculate the image size in kb/b? All I get when I search image size is resolution (h/w) and I need to determine the actual storage size of the image.

Replies are listed 'Best First'.
Re: image size in k
by archfool (Monk) on Aug 21, 2007 at 00:45 UTC
    Image::ExifTool will read the headers of most images and tell you what size the image is, its width, height, and bits per pixel. It'll even give you extra headers if you want (like camera model and make, settings, etc).
Re: image size in k
by BrowserUk (Patriarch) on Aug 20, 2007 at 23:01 UTC
    How can I calculate the image size in kb/b?

    Essentially, you don't. It will vary widely dependant upon the image format (.gif, .png, .jpg etc.), the compression mode (quallity mode for .jpg), and the image itself. An image consisting of all one color, or just 2 or 3 colors will compress much better than a complex image containing lots of colors,


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: image size in k
by holli (Abbot) on Aug 20, 2007 at 22:43 UTC
    height * width * color_depth_in_bytes / 1024


    holli, /regexed monk/
Re: image size in k
by ikegami (Patriarch) on Aug 21, 2007 at 13:37 UTC
    If the image is stored locally, you could use -s. If the image is accessible by web server, you could do a HEAD request and check for a Content-Length header.