In what scenarios could using the GD Lib as an alternative to ImageMagick be more performant?

Using the GD Lib as an alternative to ImageMagick can be more performant in scenarios where you only need basic image manipulation functionalities, such as resizing, cropping, or adding simple filters. GD Lib is a built-in PHP library, so it eliminates the need for additional installations and dependencies like ImageMagick. Additionally, GD Lib may perform better on shared hosting environments where ImageMagick is not available or restricted.

// Example of resizing an image using GD Lib
$source = imagecreatefromjpeg('image.jpg');
$width = imagesx($source);
$height = imagesy($source);
$newWidth = 200;
$newHeight = ($height / $width) * $newWidth;
$destination = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($destination, $source, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
imagejpeg($destination, 'resized_image.jpg');
imagedestroy($source);
imagedestroy($destination);