我使用梨条码2生成gif条码。梨条码2 - 保存到磁盘
这个目前的作品,我可以看到图像作为gif图像文件。因此该页面不是以HTML格式显示,而是以独立图像的形式显示。
我的代码是:
$small_graph_height = 55;
$small_graph_width = 1.2;
$large_graph_height = 55;
$large_graph_width = 1.14;
$type = "gif";
$code = "code39";
$to_browser = TRUE;
include_once "application/libraries/Image/Barcode2.php";
$ticketno='TDN4993';
$productserial_str = empty($productserial_str) ? ucfirst($ticketno) : $productserial_str;
$productserial_type = $code;
$productserial_imgtype = $type;
$productserial_bSendToBrowser = $to_browser;
$productserial_height = $large_graph_height;
$productserial_width = $large_graph_width;
$productserial_img = Image_Barcode2::draw($productserial_str, $productserial_type, $productserial_imgtype, $productserial_bSendToBrowser, $productserial_height, $productserial_width);
ob_start();
imagepng($productserial_img);
$productserial_imgBase64 = base64_encode(ob_get_contents());
ob_end_clean();
imagedestroy($productserial_img);
$image= '<img class="ProductSerial" src="data:image/' . $productserial_imgtype . ';base64,' . $productserial_imgBase64 . '">';
echo $image;
我想要做的就是直接保存此图片的服务器硬盘,而不是把它显示给用户。
我试图使用PHP的imagegif,但它不喜欢$ image是字符串格式的事实。
任何建议将受到欢迎。一如既往感谢
谢谢,我没有看到这篇文章,但不能确定如何修改现有的'$ productserial_img = Image_Barcode2 ::平局($ productserial_str,$ productserial_type,$ productserial_imgtype,$ productserial_bSendToBrowser,$ productserial_height,$ productserial_width) ;'给你的答案 – Smudger 2014-09-29 13:27:28