首页 文章

使用PHP将.BMP转换为.PNG

提问于
浏览
1

我需要能够将不同的图像格式转换为.PNG格式 . 在其他一些人的帮助下,我能够实现这一目标 . 唯一的问题是,我还需要能够在不使用ImageMagick的情况下将.BMP文件转换为.PNG .

Here is the code I used for the conversion of other files:

<?php
 $filename = "myfolder/test.jpg";
 $jpg = @imagecreatefromjpeg($filename);
 if ($jpg)
 {
   header("Content-type: image/png");
   imagepng($jpg);
   imagedestroy($jpg);
   exit;
 }
?>

如果有人知道如何转换这个,请告诉我 . 欢迎并感谢所有帮助 .

2 回答

  • 4

    GD中的标准BMP没有内置功能 . 但是,如果您查看imagecreatefromwbmp的文档页面,可以尝试其他人发布的解决方案 . 处理手动读取图像数据并从中构建GD图像资源,然后可以将其保存为任何格式 .

  • 3

    在Github上有一个新的开源项目,允许在PHP中读取和保存BMP文件(和其他文件格式) .

    该项目名为PHP Image Magician .

相关问题