最近,我们推出了店内激活功能,让你用Galaxy Tab 2拍照,然后将照片馈送到我们的中央服务器。这是使用Phonegap完成的。在服务器端,我们使用PHP和GD2来生成图像。一切都可以在服务器上运行,图像也能完美地创建出来,当我们想要用打印机打印这些照片时,问题就来了。目前我们正在使用HITI照片打印机,但同样的问题也出现在我们正常的内部打印机上,在内部打印机上,它确实打印照片,但它出来的照片太小了,页面上不超过4 4mm 2 4mm。
下面是我用PHP在服务器上生成JPEG的代码:
//define image name
$image_name = $this->genUID() .'.jpg';
//get image attributes
list($curWidth, $curHeight, $type, $attr) = getimagesize($files['my_picture']['tmp_name']);
//create image in today's directory
$nI = imagecreatefromjpeg($files['my_picture']['tmp_name']);
$nP = imagecreatetruecolor($this->minimum_image_width, $this->minimum_image_height);
$widthResizeRatio = ($this->minimum_image_width / $curWidth);
$newWidth = $this->minimum_image_width;
$newHeight = round(($curHeight * $widthResizeRatio),0);
$offsetX = 0;
$offsetY = 180;
imagecopyresampled($nP, $nI, 0, 0, $offsetX, $offsetY, $newWidth, $newHeight, $curWidth, $curHeight);
imageinterlace($nP, true);
imagejpeg($nP, $this->image_directory .'/'. $this->curDate .'/'. $image_name, 100);
imagedestroy($nI);
imagedestroy($nP);您的帮助我们将不胜感激。
发布于 2013-07-11 22:17:13
你说服务器上的所有图像都是完美创建的……我会更仔细地测试这个说法。如果确实如此,问题出在您将图像发送到打印机的方式,或者打印机在接收到图像后如何处理图像。在任何一种情况下,我都不认为你会在这里得到太多帮助……我可能错了。总帐
https://stackoverflow.com/questions/17595444
复制相似问题