How to get image size from url by using php

Today I want to present you an easy way to get image size from url by using the php language. You will be able to use this trick in your projects.

To get the image size, we need first use the php function file get contents: file_get_contents('image url');

Next, we need to use the php function strlen: strlen(file_get_contents('image url'));

The php function strlen will calculate the length of the content we get with file_get_contents and will show the length. The length is the size of the image in bytes.


I hope this way to get image size in php will be useful for you.

Leave a Comment