Take the 2-minute tour ×

I need to convert a .png file to .bmp; I'm using the outcome in printer_draw_bmp() to print out a barcode.

GD can generate WBMP, but as far as I can tell that's not the same as .bmp. How can I do this conversion? Or is there another way to print a .png directly?

share|improve this question
Have you actually tried to use wbmp? –  Jack Jul 24 '13 at 7:41
thankyou , jack :) I tried wbmp but it doesn't work .. –  santi_nc Jul 24 '13 at 7:42
Maybe you will want to highlight that in your question; it seems only speculative at this point. –  Jack Jul 24 '13 at 7:50
add comment

2 Answers

AFAIK, GD doesn't support bmp format. But you can use ImageMagick to save file in bmp format:

$im = new Imagick('image.png');

Or if you want to output image to http response:

$im = new Imagick('image.png');
echo $im;
share|improve this answer
@downvoter: Care to explain your vote –  Molecular Man Jul 24 '13 at 7:27
Not sure, ImageMagick is great. +1 –  Jack Jul 24 '13 at 7:28
I already install the ImageMagick and add the extension, but it always shows "Class 'Imagick' not found" . why ? –  santi_nc Jul 24 '13 at 8:44
@santi_nc, have you restarted apache (or whatever server you're using)? –  Molecular Man Jul 24 '13 at 8:50
It works now. but I have another problem . even the image is already converted , the printer_draw_bmp() still can't load the image . it says that the image is not bitmap . is there any different between bmp and bitmap ? –  santi_nc Jul 25 '13 at 3:57
show 1 more comment

There is a 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.

share|improve this answer
add comment

Your Answer


