Convert .BMP to .PNG with PHP
Asked Answered
L

2

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.

Lillie answered 17/10, 2010 at 23:44 Comment(0)
O
4

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.

Olimpiaolin answered 17/7, 2012 at 22:29 Comment(2)
The site is broken, it does not load the library page. But I can find the project in github github.com/Oberto/php-image-magician. But the read me also does not help.Barimah
@Mani, Yeah, sorry about that. It's down while I'm changing hosts so should be up in the next couple of days. I've added a link to github - I'll try add some documentation on Github, too.Olimpiaolin
S
3

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.

Sawyere answered 17/10, 2010 at 23:54 Comment(1)
There are more solutions at the imagecreate page.Magdalenemagdalenian

© 2022 - 2024 — McMap. All rights reserved.