How to convert .png file to .bmp?

不羁岁月 提交于 2019-12-12 10:08:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!