views:

40

answers:

1

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);
   exit;
 }
?>

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

A: 

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.

prodigitalson
There are more solutions at the [`imagecreate`](http://php.net/manual/en/function.imagecreate.php) page.
willell