What are the potential pitfalls of using imagejpeg() function in PHP for saving images?

One potential pitfall of using the imagejpeg() function in PHP for saving images is that it may not handle transparency properly, resulting in loss of image quality. To solve this issue, you can use the imagepng() function instead, which supports transparency.

// Save image with transparency using imagepng() function
$image = imagecreatefrompng('image.png');
imagepng($image, 'output.png');
imagedestroy($image);