Get image size in megapixels, total number of pixels, aspect ratio?
-
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 current featured image in post.
if ( has_post_thumbnail()) { $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full'); // echo image width echo $thumb_image_url[1]; // echo image height echo $thumb_image_url[2];
And I get for example dimensions: 1600 x 1200.
Is possible to make function to calculate width x height to get total number of pixels?
(To get for example 1.920.000 = 1600*1200)Also to transform total number of pixels in megapixels?
(To get for example 1.9 megapixels)And, also function to calculate aspect ratio based on image width and height?
(1,33:1 = 4:3)
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get image size in megapixels, total number of pixels, aspect ratio?’ is closed to new replies.