How can the size discrepancy between the downloaded image and the original image be resolved in PHP?

When downloading images in PHP, the size discrepancy between the downloaded image and the original image can be resolved by setting the `CURLOPT_FOLLOWLOCATION` option to true in the cURL request. This option allows cURL to follow any redirects and download the final image without losing its original size.

$url = 'https://example.com/original_image.jpg';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$image_data = curl_exec($ch);
curl_close($ch);

file_put_contents('downloaded_image.jpg', $image_data);