Is Image Magick a better option for changing the compression of a JPEG file in PHP?

When changing the compression of a JPEG file in PHP, Image Magick can be a better option compared to the built-in PHP functions like `imagejpeg()`. Image Magick offers more advanced features and options for manipulating images, including adjusting compression levels with more control and precision.

// Example code using Image Magick to change compression of a JPEG file
$originalFile = 'original.jpg';
$compressedFile = 'compressed.jpg';

// Create a new Imagick object
$image = new Imagick($originalFile);

// Set the compression quality (0-100)
$image->setImageCompressionQuality(80);

// Save the compressed image
$image->writeImage($compressedFile);

// Clear resources
$image->clear();
$image->destroy();