santi_nc
santi_nc

Reputation: 23

How to convert .png file to .bmp?

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?

Upvotes: 1

Views: 6144

Answers (2)

Molecular Man
Molecular Man

Reputation: 22386

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

$im = new Imagick('image.png');
$im->writeImage('image.bmp');

Or if you want to output image to http response:

$im = new Imagick('image.png');
$im->setImageFormat('bmp');
echo $im;

Upvotes: 2

Tredged
Tredged

Reputation: 501

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.

Upvotes: 3

Related Questions