问题
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?
回答1:
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.
回答2:
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;
来源:https://stackoverflow.com/questions/17827498/how-to-convert-png-file-to-bmp