From the last answer it shows that there's no objects in a raster image file. However, you can do it by searching the first occurrence of transparent colour and the first occurrence of the non-transparent colour and calculate the distance of them (assumes that your image's blank area are all transparent).
Example code:
<?php
$img = imagecreatefrompng('./frame.png');//open the image
$w = imagesx($img);//the width
$h = imagesy($img);//the height
$nonTransparentPos = null;//the first non-transparent pixel's position
$transparentPos = null;//the first transparent pixel's position
//loop through each pixel
for($x = 0; $x < $w; $x++){
for($y = 0; $y < $h; $y++){
$color = imagecolorsforindex($img,imagecolorat($img,$x,$y));
if($color['alpha'] < 127 && $nonTransparentPos === null){
$nonTransparentPos = array($x,$y);
}
if($color['alpha'] === 127 && $transparentPos === null){
$transparentPos = array($x,$y);
}
}
//leave the loop if we have finished finding the two values.
if($transparentPos !== null && $nonTransparentPos !== null){
break;
}
}
$length = $transparentPos[0]-$nonTransparentPos[0];//calculate the two point's x-axis distance
echo $length;
?>