What are the potential performance differences in using GD library for image size retrieval compared to other methods in PHP?

When retrieving image size in PHP, using the GD library can potentially offer better performance compared to other methods because GD is specifically designed for image manipulation tasks. Other methods may require additional processing steps or external libraries, which can slow down the process.

<?php
// Using GD library for image size retrieval
$image_path = 'image.jpg';
$image_size = getimagesize($image_path);
$width = $image_size[0];
$height = $image_size[1];

echo "Image width: $width, height: $height";
?>