2013-07-11 99 views
1

最近,我们推出了一项店内激活功能,让您使用Galaxy Tab 2拍摄照片,然后将其提供给我们的中央服务器。这是用Phonegap完成的。在服务器上,我们使用PHP和GD2来生成图像。一切工作在服务器上,并且图像完美地创建,问题出现在我们想用打印机打印这些照片时出现。目前,我们使用的是HITI照片打印机,但同样的问题发生在我们常规的室内打印机上,在内置打印机上打印照片,但是它的尺寸不会超过4毫米X 2毫米。PHP GD2图像不打印

下面是我使用的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); 

您的帮助将不胜感激。

回答

0

你说服务器上的所有图像都是完美创建的...我会更仔细地测试这个说法。如果确实如此,则问题在于如何将图像发送到打印机,或者打印机在接收到图像后如何处理图像。在这两种情况下,我认为你不会在这里得到很多帮助.....我可能是错的。 GL。

+0

Howzit,Thx。当我将图像从我的电脑打印到打印机时,很不幸,该设置要求将图像放置在USB闪存驱动器上,然后直接插入打印机,这是出错的地方。 –

+0

所以它听起来像图像创建正常,因此问题不在您的代码。探索打印机如何发送和处理图像 – hendr1x