开发者

Convert .BMP to .PNG with PHP

I needed to be able to convert different image formats to the .PNG format. With the help of some others, I was able to make that happen. The only issue is, I also need to be able to convert .BMP files to .PNG without the use of ImageMagick.

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);
   e开发者_如何转开发xit;
 }
?>

If anyone knows how I would go about converting this, please let me know. All help is welcome and appreciated.


There is a new opensource project on Github that allows reading and saving of BMP files (and other file formats) in PHP.

The project is called PHP Image Magician.


There is not built in functionlaity for standard BMP's in GD. However, if you look at the documentation page for imagecreatefromwbmp there are some solutions posted by others you can try. The deal with reading the image data manually and constructing a GD image resource from it which could then be saved as whatever format.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜