What are the potential limitations of using GD library for image manipulation in PHP?

One potential limitation of using the GD library for image manipulation in PHP is that it may not support all image formats. To overcome this limitation, you can use a combination of GD library functions and other libraries like Imagick to handle a wider range of image formats.

// Example of using GD library with Imagick for image manipulation
$imagePath = 'image.jpg';

// Check if Imagick extension is available
if (extension_loaded('imagick')) {
    $imagick = new Imagick($imagePath);
    
    // Use Imagick functions for image manipulation
    $imagick->resizeImage(200, 200, Imagick::FILTER_LANCZOS, 1);
    
    // Save the manipulated image
    $imagick->writeImage('output.jpg');
    $imagick->clear();
    $imagick->destroy();
} else {
    // Use GD library functions for image manipulation
    $image = imagecreatefromjpeg($imagePath);
    
    // Use GD functions for image manipulation
    $newImage = imagescale($image, 200, 200);
    
    // Save the manipulated image
    imagejpeg($newImage, 'output.jpg');
    
    // Clean up
    imagedestroy($image);
    imagedestroy($newImage);
}