$filename = 'image.jpg'; $im = imagecreatefromjpeg($filename); $width = getImageWidth($im); echo "The image width is: $width pixels";
$filename = 'image.png'; $im = imagecreatefrompng($filename); $width = getImageWidth($im); echo "The image width is: $width pixels";This example is similar to the first one, but uses the imagecreatefrompng() function to load a PNG image instead. Package library: This function is a part of the PHP GD library, which provides image manipulation capabilities in PHP.