What is the best way to determine the size of an external image in PHP?

To determine the size of an external image in PHP, you can use the getimagesize() function. This function returns an array containing the image's width and height. You can then access these values to determine the size of the image.

$url = 'https://example.com/image.jpg';
$imageSize = getimagesize($url);
$imageWidth = $imageSize[0];
$imageHeight = $imageSize[1];

echo "Image width: $imageWidth, Image height: $imageHeight";