New Composite Tag for Opened Image Size in Memory?

Started by Stephen Marsh, March 05, 2017, 10:23:17 PM

Previous topic - Next topic

Stephen Marsh

Hi Phil, you have added a composite tag for megapixels:

-Composite:Megapixels

I can see in the archives that in 2012 this feature did not exist (https://exiftool.org/forum/index.php/topic,4350.msg20705.html#msg20705).

How hard would it be to compute the file size for a decompressed/opened image in memory (not size on disk). Such as (please forgive the math example):

1600x2400px = 3,840,000px
3,840,000px x 8bits per channel = 30,720,000 / 8bits = 3,840,000 Bytes
3,840,000 Bytes / 1024 = 3750 Kilobytes / 1024 x no. of channels: 3 (R, G, B) = 10.986327mb or 11mb rounded up?

Hayo Baan

Why don't you create your own custom composite tag for this? What you want can easily be achieved :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Stephen Marsh

Hayo, as your smiley suggests, "Easily achieved" is often a relative term.

I'll take a look, however this is likely beyond my current level!

http://www.exiftool.org/config.html

StarGeek

Well technically, it would be a bit more complex.  Is it grayscale or a palette based image?  How much memory does a raw image take up in memory with 12/14/16 bits per channel?  What if you process a video file?  ;)

But assuming a quick and dirty calculation
ImageWidth*ImageHeight*(3 channels)

Human readable output routine from http://www.perlmonks.org/?node_id=378538

Seriously, don't depend upon the output from this for anything critical.  I noticed while testing that this read an xmp file pulled from an image file from a previous test and pulled the ImageWidth/Height from that to output Image Size In Memory : 3.49 MB for a 10k text file.

ImageSizeInMemory=> {
# Quick and dirty image size in memory
# Byte output from http://www.perlmonks.org/?node_id=378538
Require => {0 => 'ImageWidth',1 => 'ImageHeight'},
    ValueConv => q{
my $size=$val[0]*$val[1]*3;
my $n=0;
++$n and $size /= 1024 until $size < 1024;
    return sprintf "%.2f %s", $size, ( qw[ bytes KB MB GB TB PB ] )[ $n ];
},
},


* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Stephen Marsh