需要从JSON和电子邮件

时间:2017-11-02 14:51:09

标签: php html json image

所以我使用了来自其他来源的签名板并且垫工作正常。当我提交表单时,它将图像保存为JSON代码,这很有用,因为我还需要将其存储在数据库中。但是在提交时,我需要将代码转换为png并通过电子邮件发送图像。这是我用来将代码转换为图像的代码,$ output2是来自签名捕获的JSON代码,signature-to-image.php是实际转换图像的文件:

require_once 'signature-to-image.php';
$img = sigJsonToImage($output2);
// Save to file
imagepng($img);
// Destroy the image in memory when complete - I destroy the image at the very end of the PHP file

这段代码很好地转换了代码,因为我测试了它只打开了一个只有$ img的标题,图像显示正常。

但是,当我尝试将png图像添加到电子邮件正文时,它只显示为资源ID#7。我使用下面的代码行发送图像:

$email_message .= "Signature: ".clean_string($img)."\n";

我假设我需要将图像嵌入电子邮件的正文中(我不熟悉)或者我需要将图像作为附件发送(我也不熟悉)。我在想这个是正确的吗?哪个选项是更好的选择还是有更好的选择?

所以我在签名板中写道,它捕获签名并用JSON保存图像(据我所知,我没有使用JSON的经验)这是我将收到的输出示例:     [{" LX":46," LY":49," MX":46,"我" 48},{&# 34; LX":46," LY":48," MX":46,"我" 49},{" LX&# 34; 46" LY":51," MX":46,"我" 48},{" LX" 46 " LY":55," MX":46,"我" 51},{" LX" 46&#34 ; LY":62," MX":46,"我" 55},{" LX":47," LY&#34 ; 69" MX":46,"我" 62},{" LX":52," LY":94, " MX":47,"我" 69},{" LX":54," LY" 105" MX":52,"我" 94},{" LX":56," LY":114," MX" :54,"我" 105},{" LX":58," LY" 126" MX":56,& #34;我":114},{" LX":59," LY" 133" MX":58,"我& #34; 126},{" LX" 60" LY" 136" MX":59,"我&#34 ;: 133},{" LX" 60" LY" 140" MX" 60"我" 136},{ " LX":88," LY":25," MX":88,"我" 24},{" LX":88," LY":24," MX":88,"我":25 },{" LX":88," LY":28," MX":88,"我" 24},{& #34; LX" 89" LY":33," MX":88,"我":28},{" LX& #34;:90," LY":39," MX" 89"我" 33},{" LX&#34 ;: 91," LY":43," MX":90,"我" 39},{" LX":93,&# 34; LY" 60" MX" 91"我" 43},{" LX":94," LY&# 34; 69" MX" 93"我" 60},{" LX":96," LY" 79 " MX":94,"我" 69},{" LX" 98" LY" 94&#34 ; MX":96,"我" 79},{" LX" 99" LY":102," MX&#34 ;:98,"我" 94},{" LX":100," LY":114," MX":99, "我":102},{" LX":100," LY" 117" MX":100,"我":114},{" LX":100," LY" 118" MX":100,"我" :117},{" LX":100," LY" 120" MX":100,"我" 118}, {" LX":28," LY":116," MX":28,"我" 115},{&#34 ; LX":28," LY" 115" MX":28,"米ý":116},{" LX":28," LY":114," MX":28,"我" :115},{" LX":30," LY" 113" MX":28,"我":114}, {" LX":32," LY":112," MX":30,"我" 113},{&#34 ; LX":36," LY":110," MX":32,"我":112},{" LX&#34 ;:57," LY":104," MX":36,"我":110},{" LX":67, " LY":100," MX":57,"我":104},{" LX" 91" LY" 92" MX":67,"我":100},{" LX" 121" LY" :75," MX" 91"我" 92},{" LX" 127" LY":72,& #34; MX" 121"我" 75},{" LX" 129" LY":72," MX& #34; 127"我" 72},{" LX" 130" LY":72," MX&#34 ;: 129,"我" 72},{" LX" 130" LY":73," MX" 130&# 34;我" 72},{" LX" 196" LY":48," MX" 196"我&# 34; 47},{" LX" 196" LY":47," MX" 196"我" 48 },{" LX" 198" LY" 45&#34 ; MX" 196"我" 47},{" LX":200," LY":43," MX&#34 ;:198,"我" 45},{" LX":204," LY":42," MX":200, "我" 43},{" LX":209," LY":41," MX":204,"我" 42},{" LX":219," LY" 40" MX":209,"我" :41},{" LX" 232" LY":39," MX":219,"我" 40}, {" LX" 238" LY":39," MX" 232"我" 39},{&#34 ; LX" 244" LY":39," MX" 238"我" 39},{" LX&#34 ;:257," LY":38," MX" 244"我" 39},{" LX":261, " LY":38," MX":257,"我" 38},{" LX" 263" LY":38," MX":261,"我" 38},{" LX":223," LY" :42," MX":223,"我":41},{" LX":223," LY":41,& #34; MX":223,"我" 42},{" LX":223," LY":44," MX& #34;:223,"我":41},{" LX":223," LY":45," MX&#34 ;: 223,"我" 44},{" LX":223, " LY" 50" MX":223,"我" 45},{" LX":223," LY":52," MX":223,"我" 50},{" LX":223," LY" :56," MX":223,"我" 52},{" LX":223," LY":75,& #34; MX":223,"我" 56},{" LX":223," LY":84," MX& #34;:223,"我" 75},{" LX":223," LY" 91" MX&#34 ;: 223,"我" 84},{" LX":223," LY":110," MX":223,&# 34;我" 91},{" LX":223," LY" 119" MX":223,"我&# 34;:110},{" LX":223," LY" 123" MX":223,"我":119 },{" LX":223," LY" 127" MX":223,"我" 123},{& #34; LX":222," LY" 129" MX":223,"我" 127},{" LX& #34;:221," LY" 129" MX":222,"我" 129},{" LX&#34 ;: 219," LY" 130" MX":221,"我" 129},{" LX" 217&# 34; LY" 130" MX":219,"我" 130},{" LX":211," LY&# 34; 131" MX":217 "我" 130},{" LX":201," LY" 131" MX":211,&#34 ;我" 131},{" LX" 192" LY" 132" MX":201,"我&#34 ;:131},{" LX":181," LY" 132" MX" 192"我" 132} ,{" LX":177," LY" 132" MX":181,"我" 132},{&# 34; LX":173," LY" 132" MX":177,"我" 132},{" LX&# 34; 163" LY" 132" MX":173,"我" 132},{" LX":161 " LY" 132" MX" 163"我" 132},{" LX":159,&#34 ; LY" 132" MX" 161"我" 132},{" LX" 161" LY&#34 ; 132" MX":159,"我" 132},{" LX" 166" LY":131, " MX" 161"我" 132},{" LX" 172" LY" 130" MX" 166"我" 131},{" LX" 176" LY" 130" MX" :172,"我" 130},{" LX" 192" LY" 130" MX":176,& #34;我" 130},{" LX" 203" LY" 130" MX" 192"我& #34; 130},{ " LX":211," LY" 130" MX" 203"我" 130},{" LX":219," LY" 130" MX":211,"我" 130},{" LX" :222," LY" 130" MX":219,"我" 130},{" LX":228,& #34; LY" 130" MX":222,"我" 130},{" LX" 232" LY& #34; 130" MX":228,"我" 130},{" LX" 235" LY&#34 ;: 130," MX" 232"我" 130},{" LX":240," LY" 130&# 34; MX" 235"我" 130},{" LX":241," LY" 130" MX&# 34;:240,"我" 130},{" LX":242," LY" 130" MX":241 "我" 130},{" LX":243," LY" 130" MX":242,&#34 ;我" 130},{" LX":246," LY" 130" MX":243,"我&#34 ;:130},{" LX" 250" LY" 129" MX":246,"我" 130} ,{" LX":261," LY":128," MX" 250"我" 129},{&# 34; LX" 265" LY":128," MX":261,"我":128},{" LX&# 34;:267,&#3 4; LY" 127" MX" 265"我":128},{" LX" 269" LY&# 34; 127" MX":267,"我" 127}]

0 个答案:

没有答案