1

We need to create a 1 bit BMP file to send it to a printer. Apparently the file should be a headerless bmp file. I found that that could be just removing the first 45 bytes.

I got something like this, but it aint working:

$filename = APPPATH.'../assets/test.prn';
$im = @imagecreate(432, 20) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im, $filename);
imagedestroy($im);
$im = new Imagick();
$im->readimage($filename);
$im->resizeimage(432, 20, Imagick::FILTER_UNDEFINED, 1, false);
$im->posterizeimage(2, false);
$im->writeimage($filename.".bmp");

This is just to try and make a 1 bit image file. But it is not headerless and it isn't a bmp.

4

1 回答 1

-1

你在安装 Imagick 时有任何问题吗,有评论说它对某些 PHP 版本有点棘手。

于 2014-03-27T10:05:43.240 回答