What are the implications of using imagejpeg with a quality value of 100 when generating thumbnails in PHP?

Using imagejpeg with a quality value of 100 can result in unnecessarily large file sizes for thumbnails, which can impact loading times and storage space. To optimize thumbnails, it is recommended to use a lower quality value, such as 80 or 90, which can still maintain good image quality while reducing file size.

// Generate thumbnail with optimized quality
$source = 'original_image.jpg';
$thumbnail = 'thumbnail.jpg';

$source_img = imagecreatefromjpeg($source);
$thumb_width = 100;
$thumb_height = 100;
$thumb_img = imagecreatetruecolor($thumb_width, $thumb_height);

imagecopyresampled($thumb_img, $source_img, 0, 0, 0, 0, $thumb_width, $thumb_height, imagesx($source_img), imagesy($source_img));

// Save thumbnail with quality value of 80
imagejpeg($thumb_img, $thumbnail, 80);

// Free up memory
imagedestroy($source_img);
imagedestroy($thumb_img);