Is it possible to show total number of pixels, size in MP, aspect ratio of current featured image?

For example I use this to echo image dimensions of full sized featured image of current post.

if ( has_post_thumbnail()) {
   $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), 'full');

// echo image width
echo $thumb_image_url[1];
// echo image height
echo $thumb_image_url[2];


And I get for example dimensions: 2048 x 1536.

Is it possible to make separate functions to calculate: 


Total number of pixels width x height? (example 2048 x 1536 = 3.145.728 pixels)
Transform total number of pixels in megapixels? (3.14 megapixel)
Function to calculate aspect ratio based on image width and height? (1,33:1 - 4:3 (screen))


More info about megapixel and aspect ratio calculator on:
http://web.forret.com/tools/megapixel.asp



I would go little further also.
I think it is possible to get aspect ratio as: standard (lansdcape), portrait or square (approximately).

Standard (most used) image aspect ratio width / height is 4:3, landscape, which is mathematically also 1:1.3333333333333 (example 1600 x 1200 pixels photo).

Portrait would be 0.75 (example 1600 x 1200 pixels photo).

And square would be 1:1 ((example 1200 x 1200 pixels photo).

What I think would be great is to make function which will check result of aspect ratio.

If it is 1.33 (or even better if it is more than 1.2 in case image is little cropped) than to return "Landscape image".

If it is 0.75 (or even better if it is less than 0.8 in case image is little cropped) than to return "Portrait image".

If it is more that 0.8 but less than 1.2 than to return "Square like".

Any suggestions?


Question: Does this C++ static analysis rule make sense as is?
Answer: In C++11, #2 and #4 can be made safe if there are also rvalue reference overloads. Thus:

const int *get( const int &amp;x ) { return &amp;x; }
const int *get( const int &amp;&amp;x ) { return nullptr; }

void test() {
    const int x = 0;
    const int *p1 = get( x ); // OK; p1 is &amp;x.
    const int *p2 = get( x+42 ); // OK; p2 is nullptr.
}


So although they are dodgy, they do have safe uses if the programmer knows what they are doing. It'd be draconian to forbid this.

(Perhaps safer would be if the const rvalue reference overload was made private, left undefined, or otherwise caused a compile-time or link-time error. This is especially true for the #4 case, where we return a reference but there is nothing good to return a reference to and the language doesn't allow references to null.)