Convert jpg image to gif, png & bmp format using PHP

时间:2021-07-30 21:24:32

How can I convert a single jpg image into 3 different image format gif , png and bmp using PHP?

如何使用PHP将单个jpg图像转换为3种不同的图像格式gif,png和bmp?

Pls help

请帮忙

3 个解决方案

#1


39  

You first create an image object out of your file with imagecreatefromjpeg(). You then dump that object into different formats (using imagegif() for example):

首先使用imagecreatefromjpeg()从文件中创建一个图像对象。然后,您将该对象转储为不同的格式(例如,使用imagegif()):

$imageObject = imagecreatefromjpeg($imageFile);
imagegif($imageObject, $imageFile . '.gif');
imagepng($imageObject, $imageFile . '.png');
imagewbmp($imageObject, $imageFile . '.bmp');

#2


5  

Use libGD — http://www.php.net/manual/en/book.image.php

使用libGD - http://www.php.net/manual/en/book.image.php

#3


2  

I've set up a new opensource project on Github that allows reading and saving of BMP files (actual BMP files, not wbmp), and other file formats, in PHP. It's nice and easy to use.

我在Github上设置了一个新的开源项目,它允许在PHP中读取和保存BMP文件(实际的BMP文件,而不是wbmp)和其他文件格式。它很好用且易于使用。

The project is called PHP Image Magician.

该项目名为PHP Image Magician。

#1


39  

You first create an image object out of your file with imagecreatefromjpeg(). You then dump that object into different formats (using imagegif() for example):

首先使用imagecreatefromjpeg()从文件中创建一个图像对象。然后,您将该对象转储为不同的格式(例如,使用imagegif()):

$imageObject = imagecreatefromjpeg($imageFile);
imagegif($imageObject, $imageFile . '.gif');
imagepng($imageObject, $imageFile . '.png');
imagewbmp($imageObject, $imageFile . '.bmp');

#2


5  

Use libGD — http://www.php.net/manual/en/book.image.php

使用libGD - http://www.php.net/manual/en/book.image.php

#3


2  

I've set up a new opensource project on Github that allows reading and saving of BMP files (actual BMP files, not wbmp), and other file formats, in PHP. It's nice and easy to use.

我在Github上设置了一个新的开源项目,它允许在PHP中读取和保存BMP文件(实际的BMP文件,而不是wbmp)和其他文件格式。它很好用且易于使用。

The project is called PHP Image Magician.

该项目名为PHP Image Magician。