To convert a GIF image to JPG format using PHP, you can use the GD library. Here's an example code:
<?php
// Path to the GIF image
$gifFile = 'path/to/image.gif';
// Load the GIF image
$gif = imagecreatefromgif($gifFile);
// Create a new blank JPG image with the same dimensions as the GIF
$jpg = imagecreatetruecolor(imagesx($gif), imagesy($gif));
// Convert the GIF image to JPG
imagecopy($jpg, $gif, 0, 0, 0, 0, imagesx($gif), imagesy($gif));
// Save the JPG image
$jpgFile = 'path/to/save/image.jpg';
imagejpeg($jpg, $jpgFile, 100);
// Free up memory
imagedestroy($gif);
imagedestroy($jpg);
echo 'GIF converted to JPG successfully!';
?>
Make sure to replace 'path/to/image.gif'
with the actual path to your GIF image, and 'path/to/save/image.jpg'
with the desired path to save the converted JPG image.
Note: The code assumes that the GD library is enabled on your PHP server.
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站