Topaz Signature Pad in Web Application Running on Linux Apache2 Server

I am trying to incorporate an electronic signature using the Topaz Systems signature pad into my Web Application.  

Currently I am using Thomas Bradley's HTML5 Canvas signature pad for input as well as image regeneration later for reports, and would like to have the same control using the physical signature pad.

The pad runs through the signature fine, and I can get the raw information to pass onto the PHP page for processing.  The issue I am running into is because the sample PHP script found here must be run on a Windows IIS server to access, instantiate, and use the COM PHP class and I am running on a LAMP server I cannot create an image on the server side.

An image is able to be created on the client side before the form is submitted using the ActiveX controls I can create and store an image on the local computer.  I do not want to have to have the user manually upload their signature, as it is currently all automated.

Is there a way to either create the image on the client side and automatically upload the image, or is there any other way of converting the raw SigPlus data into something usuable on the server side of things?
PhillipsPlasticsAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
This version is a little easier to see on the screen.
http://www.laprbass.com/RAY_temp_philplastic_3.php

 
<?php // RAY_temp_philplastic_3.php
error_reporting(E_ALL);


function hextostr($x)
{
    $s='';
    foreach(explode(PHP_EOL,trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
    return($s);
}


$str = '3332320D0A340D0A333931203231340D0A333930203231340D0A333930203231340D0A333930203231340D0A333931203231340D0A333931203231350D0A333931203231370D0A333931203232300D0A333930203232340D0A333930203232390D0A333839203233360D0A333837203234330D0A333835203235320D0A333832203236310D0A333739203237310D0A333735203238320D0A333731203239320D0A333637203330330D0A333632203331330D0A333538203332330D0A333534203333320D0A333530203334300D0A333437203334380D0A333434203335340D0A333432203335390D0A333431203336340D0A333431203336370D0A333430203336390D0A333431203337310D0A333431203337310D0A333432203337310D0A333434203337300D0A333436203336390D0A333438203336360D0A333530203336320D0A333533203335370D0A333535203335310D0A333538203334350D0A333631203333380D0A333634203333310D0A333637203332340D0A333731203331360D0A333735203330380D0A333830203330300D0A333836203239310D0A333931203238310D0A333937203237310D0A343033203236310D0A343130203235300D0A343136203233390D0A343233203232380D0A343330203231380D0A343336203230390D0A343432203230300D0A343437203139340D0A343530203138380D0A343533203138350D0A343535203138320D0A343536203138300D0A343537203138300D0A343538203138300D0A343538203138310D0A343538203138340D0A343538203138380D0A343538203139350D0A343539203230330D0A343538203231330D0A343538203232350D0A343537203233380D0A343537203235320D0A343537203236360D0A343536203238310D0A343536203239350D0A343536203330390D0A343537203332330D0A343538203333370D0A343539203334390D0A343631203336300D0A343632203337300D0A343633203337390D0A343635203338370D0A343636203339330D0A343637203339380D0A343638203430320D0A343639203430350D0A343639203430360D0A343639203430360D0A343639203430360D0A333537203330310D0A333538203330300D0A333630203239390D0A333634203239380D0A333639203239360D0A333735203239340D0A333831203239330D0A333838203239330D0A333934203239320D0A343031203239320D0A343037203239320D0A343134203239320D0A343230203239320D0A343236203239310D0A343332203239300D0A343338203238380D0A343432203238360D0A343434203238360D0A343435203238350D0A343434203238350D0A363034203233300D0A363033203233300D0A363033203233300D0A363033203233310D0A363033203233320D0A363033203233350D0A363034203233390D0A363035203234340D0A363036203235310D0A363037203236300D0A363039203236390D0A363130203237390D0A363132203238380D0A363134203239380D0A363136203330370D0A363139203331350D0A363231203332330D0A363233203333300D0A363235203333360D0A363236203334310D0A363237203334350D0A363238203334390D0A363239203335310D0A363239203335330D0A363330203335350D0A363330203335360D0A363331203335360D0A363331203335360D0A363331203335360D0A363330203335340D0A363239203335310D0A363238203334380D0A363236203334330D0A363235203333370D0A363232203333300D0A363230203332320D0A363137203331320D0A363133203330320D0A363039203239300D0A363035203237370D0A363031203236340D0A353936203235320D0A353932203234310D0A353838203233300D0A353835203232310D0A353831203231320D0A353738203230350D0A353735203139380D0A353732203139330D0A353639203138380D0A353636203138330D0A353634203137380D0A353632203137340D0A353630203137310D0A353538203136370D0A353536203136340D0A353535203136320D0A353535203136300D0A353534203135390D0A353534203135390D0A353534203135380D0A353533203135380D0A353533203135390D0A353533203136300D0A353533203136310D0A353533203136320D0A353533203136330D0A353533203136350D0A353533203136360D0A353533203136380D0A353533203137300D0A353533203137310D0A353533203137320D0A353533203137330D0A353533203137340D0A353533203137350D0A353533203137350D0A353534203137360D0A353535203137370D0A353537203137370D0A353630203137370D0A353634203137360D0A353639203137350D0A353737203137340D0A353836203137330D0A353936203137320D0A363039203137320D0A363232203137320D0A363336203137330D0A363530203137360D0A363633203137390D0A363736203138340D0A363836203138390D0A363935203139350D0A373030203230310D0A373034203230370D0A373035203231340D0A373034203232300D0A373031203232360D0A363937203233320D0A363932203233370D0A363835203234320D0A363738203234360D0A363730203234390D0A363632203235310D0A363535203235310D0A363438203235310D0A363433203235300D0A363339203234390D0A363337203234380D0A363336203234370D0A363336203234360D0A363338203234340D0A363432203234340D0A363438203234340D0A363537203234340D0A363638203234360D0A363831203234390D0A363935203235320D0A373131203235370D0A373237203236330D0A373434203236390D0A373630203237360D0A373734203238320D0A373836203238390D0A373935203239360D0A383031203330330D0A383035203331300D0A383036203331360D0A383036203332330D0A383033203332390D0A373935203333360D0A373835203334330D0A373733203334380D0A373539203335310D0A373437203335330D0A373334203335330D0A373230203335320D0A373036203334390D0A363933203334360D0A363830203334320D0A363637203333370D0A363536203333330D0A363437203332380D0A363339203332350D0A363333203332310D0A363239203331390D0A363236203331370D0A363234203331350D0A363234203331340D0A363234203331330D0A363234203331320D0A363234203331320D0A363234203331320D0A393537203139390D0A393537203139380D0A393537203139360D0A393538203139330D0A393538203139300D0A393538203138380D0A393535203138370D0A393531203138370D0A393436203138390D0A393430203139320D0A393333203139370D0A393235203230340D0A393138203231320D0A393131203232310D0A393035203233310D0A393031203234320D0A383938203235330D0A383936203236350D0A383937203237360D0A383939203238370D0A393034203239370D0A393130203330360D0A393138203331330D0A393238203331390D0A393430203332330D0A393534203332360D0A393639203332370D0A393835203332370D0A31303031203332370D0A31303137203332360D0A31303332203332340D0A31303436203332320D0A31303539203332300D0A31303730203331370D0A31303830203331350D0A31303837203331330D0A31303933203331310D0A31303937203330390D0A31313030203330380D0A31313031203330360D0A31313031203330350D0A31313031203330340D0A31303939203330330D0A31303937203330330D0A31303935203330330D0A31303932203330330D0A31303839203330340D0A31303835203330350D0A31303832203330360D0A31303739203330370D0A31303736203330390D0A31303734203331300D0A31303733203331310D0A31303731203331310D0A31303730203331320D0A31303638203331320D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A300D0A38380D0A3130380D0A3236320D0A00000000000000000000000000000000000000000000000000000000000000000000';

$new = rtrim($str, '0');
$nnn = hextostr($new);

// TIDY UP SOME OF THE CRYPTIC STUFF
$arr = explode(PHP_EOL, $nnn);
$arr = array_slice($arr, 0, 323);
$arr = array_slice($arr, 2);
foreach ($arr as $key => $val) $arr[$key] = trim($val);


// DETERMINE THE CANVAS CORNERS
$lo_x = 999999;
$hi_x = 0;
$lo_y = 999999;
$hi_y = 0;

foreach ($arr as $xy)
{
    $xyc = explode(' ', $xy);
    if ($xyc[0] < $lo_x) $lo_x = $xyc[0];
    if ($xyc[0] > $hi_x) $hi_x = $xyc[0];
    if ($xyc[1] < $lo_y) $lo_y = $xyc[1];
    if ($xyc[1] > $hi_y) $hi_y = $xyc[1];
}

// echo PHP_EOL . "THE CANVAS CORNERS ARE $lo_x, $lo_y AND $hi_x, $hi_y";


// FILL THE CANVAS WITH FALSE
$x = $lo_x;
while ($x <= $hi_x)
{
    $y = $lo_y;
    while ($y <= $hi_y)
    {
        $matrix[$x][$y] = FALSE;
        $y++;
    }
    $x++;
}


// FILL IN THE DARK PARTS WITH TRUE
foreach ($arr as $xy)
{
        $xyc = explode(' ', $xy);
        $matrix[$xyc[0]][$xyc[1]] = TRUE;
}


// CREATE AN IMAGE RESOURCE
$im = imagecreatetruecolor($hi_x, $hi_y);

// SET OUR COLORS
$bgcolor = imagecolorallocatealpha($im, 255, 255, 255,   0);
$pixel   = imagecolorallocatealpha($im,   1,   1,   1,   0);
$border  = imagecolorallocatealpha($im,   1,   1,   1,   0);

// FILL THE BACKGROUND
imagefilledrectangle($im, 0, 0, $hi_x, $hi_y, $bgcolor);
imagealphablending($im, TRUE);
imagesavealpha($im, TRUE);

// FILL IN THE PIXELS, AS NEEDED
$x = $lo_x;
while ($x <= $hi_x)
{
    $y = $lo_y;
    while ($y <= $hi_y)
    {
        if ($matrix[$x][$y])
        {
            // THE EXACT PIXEL
            imagesetpixel($im, $x, $y, $pixel);

            // SURROUNDING PIXELS
            imagesetpixel($im, $x-1, $y,   $border);
            imagesetpixel($im, $x+1, $y,   $border);
            imagesetpixel($im, $x,   $y-1, $border);
            imagesetpixel($im, $x,   $y+1, $border);
        }
        $y++;
    }
    $x++;
}


// PRODUCE A PNG IMAGE
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);

Open in new window

topaz.png
0
 
racmail2001Commented:
can you post some raw SigPlus data to be able to se eif it can recreate something?
let's say draw some letters like ABC or something

0
 
racmail2001Commented:
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
PhillipsPlasticsAuthor Commented:
Yes I have tried the demo and read over all of the documentation in an attempt to understand how I might go about doing what I need it to do.

See attached txt file for output of a handdrawn "ABC" which is the raw SigData sent to a PHP file via POST and just echo'd out.

I have attempted to use the base64_decode and try and put it back into a bmp or jpg with no luck as well.
ABC.txt
0
 
Ray PaseurCommented:
See http://www.laprbass.com/RAY_temp_philplastic.php for an example of what the base64_decode() string looks like.  I am fairly sure this is not image data.
<?php // RAY_temp_philplastic.php
error_reporting(E_ALL);

$str = '3332320D0A340D0A333931203231340D0A333930203231340D0A333930203231340D0A333930203231340D0A333931203231340D0A333931203231350D0A333931203231370D0A333931203232300D0A333930203232340D0A333930203232390D0A333839203233360D0A333837203234330D0A333835203235320D0A333832203236310D0A333739203237310D0A333735203238320D0A333731203239320D0A333637203330330D0A333632203331330D0A333538203332330D0A333534203333320D0A333530203334300D0A333437203334380D0A333434203335340D0A333432203335390D0A333431203336340D0A333431203336370D0A333430203336390D0A333431203337310D0A333431203337310D0A333432203337310D0A333434203337300D0A333436203336390D0A333438203336360D0A333530203336320D0A333533203335370D0A333535203335310D0A333538203334350D0A333631203333380D0A333634203333310D0A333637203332340D0A333731203331360D0A333735203330380D0A333830203330300D0A333836203239310D0A333931203238310D0A333937203237310D0A343033203236310D0A343130203235300D0A343136203233390D0A343233203232380D0A343330203231380D0A343336203230390D0A343432203230300D0A343437203139340D0A343530203138380D0A343533203138350D0A343535203138320D0A343536203138300D0A343537203138300D0A343538203138300D0A343538203138310D0A343538203138340D0A343538203138380D0A343538203139350D0A343539203230330D0A343538203231330D0A343538203232350D0A343537203233380D0A343537203235320D0A343537203236360D0A343536203238310D0A343536203239350D0A343536203330390D0A343537203332330D0A343538203333370D0A343539203334390D0A343631203336300D0A343632203337300D0A343633203337390D0A343635203338370D0A343636203339330D0A343637203339380D0A343638203430320D0A343639203430350D0A343639203430360D0A343639203430360D0A343639203430360D0A333537203330310D0A333538203330300D0A333630203239390D0A333634203239380D0A333639203239360D0A333735203239340D0A333831203239330D0A333838203239330D0A333934203239320D0A343031203239320D0A343037203239320D0A343134203239320D0A343230203239320D0A343236203239310D0A343332203239300D0A343338203238380D0A343432203238360D0A343434203238360D0A343435203238350D0A343434203238350D0A363034203233300D0A363033203233300D0A363033203233300D0A363033203233310D0A363033203233320D0A363033203233350D0A363034203233390D0A363035203234340D0A363036203235310D0A363037203236300D0A363039203236390D0A363130203237390D0A363132203238380D0A363134203239380D0A363136203330370D0A363139203331350D0A363231203332330D0A363233203333300D0A363235203333360D0A363236203334310D0A363237203334350D0A363238203334390D0A363239203335310D0A363239203335330D0A363330203335350D0A363330203335360D0A363331203335360D0A363331203335360D0A363331203335360D0A363330203335340D0A363239203335310D0A363238203334380D0A363236203334330D0A363235203333370D0A363232203333300D0A363230203332320D0A363137203331320D0A363133203330320D0A363039203239300D0A363035203237370D0A363031203236340D0A353936203235320D0A353932203234310D0A353838203233300D0A353835203232310D0A353831203231320D0A353738203230350D0A353735203139380D0A353732203139330D0A353639203138380D0A353636203138330D0A353634203137380D0A353632203137340D0A353630203137310D0A353538203136370D0A353536203136340D0A353535203136320D0A353535203136300D0A353534203135390D0A353534203135390D0A353534203135380D0A353533203135380D0A353533203135390D0A353533203136300D0A353533203136310D0A353533203136320D0A353533203136330D0A353533203136350D0A353533203136360D0A353533203136380D0A353533203137300D0A353533203137310D0A353533203137320D0A353533203137330D0A353533203137340D0A353533203137350D0A353533203137350D0A353534203137360D0A353535203137370D0A353537203137370D0A353630203137370D0A353634203137360D0A353639203137350D0A353737203137340D0A353836203137330D0A353936203137320D0A363039203137320D0A363232203137320D0A363336203137330D0A363530203137360D0A363633203137390D0A363736203138340D0A363836203138390D0A363935203139350D0A373030203230310D0A373034203230370D0A373035203231340D0A373034203232300D0A373031203232360D0A363937203233320D0A363932203233370D0A363835203234320D0A363738203234360D0A363730203234390D0A363632203235310D0A363535203235310D0A363438203235310D0A363433203235300D0A363339203234390D0A363337203234380D0A363336203234370D0A363336203234360D0A363338203234340D0A363432203234340D0A363438203234340D0A363537203234340D0A363638203234360D0A363831203234390D0A363935203235320D0A373131203235370D0A373237203236330D0A373434203236390D0A373630203237360D0A373734203238320D0A373836203238390D0A373935203239360D0A383031203330330D0A383035203331300D0A383036203331360D0A383036203332330D0A383033203332390D0A373935203333360D0A373835203334330D0A373733203334380D0A373539203335310D0A373437203335330D0A373334203335330D0A373230203335320D0A373036203334390D0A363933203334360D0A363830203334320D0A363637203333370D0A363536203333330D0A363437203332380D0A363339203332350D0A363333203332310D0A363239203331390D0A363236203331370D0A363234203331350D0A363234203331340D0A363234203331330D0A363234203331320D0A363234203331320D0A363234203331320D0A393537203139390D0A393537203139380D0A393537203139360D0A393538203139330D0A393538203139300D0A393538203138380D0A393535203138370D0A393531203138370D0A393436203138390D0A393430203139320D0A393333203139370D0A393235203230340D0A393138203231320D0A393131203232310D0A393035203233310D0A393031203234320D0A383938203235330D0A383936203236350D0A383937203237360D0A383939203238370D0A393034203239370D0A393130203330360D0A393138203331330D0A393238203331390D0A393430203332330D0A393534203332360D0A393639203332370D0A393835203332370D0A31303031203332370D0A31303137203332360D0A31303332203332340D0A31303436203332320D0A31303539203332300D0A31303730203331370D0A31303830203331350D0A31303837203331330D0A31303933203331310D0A31303937203330390D0A31313030203330380D0A31313031203330360D0A31313031203330350D0A31313031203330340D0A31303939203330330D0A31303937203330330D0A31303935203330330D0A31303932203330330D0A31303839203330340D0A31303835203330350D0A31303832203330360D0A31303739203330370D0A31303736203330390D0A31303734203331300D0A31303733203331310D0A31303731203331310D0A31303730203331320D0A31303638203331320D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A300D0A38380D0A3130380D0A3236320D0A00000000000000000000000000000000000000000000000000000000000000000000';
$new = base64_decode($str);
var_dump($new);

Open in new window

0
 
PhillipsPlasticsAuthor Commented:
Correct I was only stating that I had tried it to cover that base.
0
 
PhillipsPlasticsAuthor Commented:
If you do a base 64 decode of that data you will get something like what you have on your test page. The data I posted is the raw signature data
0
 
Ray PaseurCommented:
This might be a character representation of a hexadecimal string.  The 0D0A sequences appear to be end-of-line information.  See my latest test at http://www.laprbass.com/RAY_temp_philplastic.php -- looks like it might be some kind of location mapping?
<?php // RAY_temp_philplastic.php
error_reporting(E_ALL);

$str = '3332320D0A340D0A333931203231340D0A333930203231340D0A333930203231340D0A333930203231340D0A333931203231340D0A333931203231350D0A333931203231370D0A333931203232300D0A333930203232340D0A333930203232390D0A333839203233360D0A333837203234330D0A333835203235320D0A333832203236310D0A333739203237310D0A333735203238320D0A333731203239320D0A333637203330330D0A333632203331330D0A333538203332330D0A333534203333320D0A333530203334300D0A333437203334380D0A333434203335340D0A333432203335390D0A333431203336340D0A333431203336370D0A333430203336390D0A333431203337310D0A333431203337310D0A333432203337310D0A333434203337300D0A333436203336390D0A333438203336360D0A333530203336320D0A333533203335370D0A333535203335310D0A333538203334350D0A333631203333380D0A333634203333310D0A333637203332340D0A333731203331360D0A333735203330380D0A333830203330300D0A333836203239310D0A333931203238310D0A333937203237310D0A343033203236310D0A343130203235300D0A343136203233390D0A343233203232380D0A343330203231380D0A343336203230390D0A343432203230300D0A343437203139340D0A343530203138380D0A343533203138350D0A343535203138320D0A343536203138300D0A343537203138300D0A343538203138300D0A343538203138310D0A343538203138340D0A343538203138380D0A343538203139350D0A343539203230330D0A343538203231330D0A343538203232350D0A343537203233380D0A343537203235320D0A343537203236360D0A343536203238310D0A343536203239350D0A343536203330390D0A343537203332330D0A343538203333370D0A343539203334390D0A343631203336300D0A343632203337300D0A343633203337390D0A343635203338370D0A343636203339330D0A343637203339380D0A343638203430320D0A343639203430350D0A343639203430360D0A343639203430360D0A343639203430360D0A333537203330310D0A333538203330300D0A333630203239390D0A333634203239380D0A333639203239360D0A333735203239340D0A333831203239330D0A333838203239330D0A333934203239320D0A343031203239320D0A343037203239320D0A343134203239320D0A343230203239320D0A343236203239310D0A343332203239300D0A343338203238380D0A343432203238360D0A343434203238360D0A343435203238350D0A343434203238350D0A363034203233300D0A363033203233300D0A363033203233300D0A363033203233310D0A363033203233320D0A363033203233350D0A363034203233390D0A363035203234340D0A363036203235310D0A363037203236300D0A363039203236390D0A363130203237390D0A363132203238380D0A363134203239380D0A363136203330370D0A363139203331350D0A363231203332330D0A363233203333300D0A363235203333360D0A363236203334310D0A363237203334350D0A363238203334390D0A363239203335310D0A363239203335330D0A363330203335350D0A363330203335360D0A363331203335360D0A363331203335360D0A363331203335360D0A363330203335340D0A363239203335310D0A363238203334380D0A363236203334330D0A363235203333370D0A363232203333300D0A363230203332320D0A363137203331320D0A363133203330320D0A363039203239300D0A363035203237370D0A363031203236340D0A353936203235320D0A353932203234310D0A353838203233300D0A353835203232310D0A353831203231320D0A353738203230350D0A353735203139380D0A353732203139330D0A353639203138380D0A353636203138330D0A353634203137380D0A353632203137340D0A353630203137310D0A353538203136370D0A353536203136340D0A353535203136320D0A353535203136300D0A353534203135390D0A353534203135390D0A353534203135380D0A353533203135380D0A353533203135390D0A353533203136300D0A353533203136310D0A353533203136320D0A353533203136330D0A353533203136350D0A353533203136360D0A353533203136380D0A353533203137300D0A353533203137310D0A353533203137320D0A353533203137330D0A353533203137340D0A353533203137350D0A353533203137350D0A353534203137360D0A353535203137370D0A353537203137370D0A353630203137370D0A353634203137360D0A353639203137350D0A353737203137340D0A353836203137330D0A353936203137320D0A363039203137320D0A363232203137320D0A363336203137330D0A363530203137360D0A363633203137390D0A363736203138340D0A363836203138390D0A363935203139350D0A373030203230310D0A373034203230370D0A373035203231340D0A373034203232300D0A373031203232360D0A363937203233320D0A363932203233370D0A363835203234320D0A363738203234360D0A363730203234390D0A363632203235310D0A363535203235310D0A363438203235310D0A363433203235300D0A363339203234390D0A363337203234380D0A363336203234370D0A363336203234360D0A363338203234340D0A363432203234340D0A363438203234340D0A363537203234340D0A363638203234360D0A363831203234390D0A363935203235320D0A373131203235370D0A373237203236330D0A373434203236390D0A373630203237360D0A373734203238320D0A373836203238390D0A373935203239360D0A383031203330330D0A383035203331300D0A383036203331360D0A383036203332330D0A383033203332390D0A373935203333360D0A373835203334330D0A373733203334380D0A373539203335310D0A373437203335330D0A373334203335330D0A373230203335320D0A373036203334390D0A363933203334360D0A363830203334320D0A363637203333370D0A363536203333330D0A363437203332380D0A363339203332350D0A363333203332310D0A363239203331390D0A363236203331370D0A363234203331350D0A363234203331340D0A363234203331330D0A363234203331320D0A363234203331320D0A363234203331320D0A393537203139390D0A393537203139380D0A393537203139360D0A393538203139330D0A393538203139300D0A393538203138380D0A393535203138370D0A393531203138370D0A393436203138390D0A393430203139320D0A393333203139370D0A393235203230340D0A393138203231320D0A393131203232310D0A393035203233310D0A393031203234320D0A383938203235330D0A383936203236350D0A383937203237360D0A383939203238370D0A393034203239370D0A393130203330360D0A393138203331330D0A393238203331390D0A393430203332330D0A393534203332360D0A393639203332370D0A393835203332370D0A31303031203332370D0A31303137203332360D0A31303332203332340D0A31303436203332320D0A31303539203332300D0A31303730203331370D0A31303830203331350D0A31303837203331330D0A31303933203331310D0A31303937203330390D0A31313030203330380D0A31313031203330360D0A31313031203330350D0A31313031203330340D0A31303939203330330D0A31303937203330330D0A31303935203330330D0A31303932203330330D0A31303839203330340D0A31303835203330350D0A31303832203330360D0A31303739203330370D0A31303736203330390D0A31303734203331300D0A31303733203331310D0A31303731203331310D0A31303730203331320D0A31303638203331320D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A300D0A38380D0A3130380D0A3236320D0A00000000000000000000000000000000000000000000000000000000000000000000';
$new = base64_decode($str);

$nnn = hextostr($str);
echo "<pre>";
var_dump($nnn);



function hextostr($x)
{
    $s='';
    foreach(explode("\n",trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
    return($s);
}

function hexpurify($str)
{
    $str = str_replace('0', NULL, $str);
    $str = str_replace('1', NULL, $str);
    $str = str_replace('2', NULL, $str);
    $str = str_replace('3', NULL, $str);
    $str = str_replace('4', NULL, $str);
    $str = str_replace('5', NULL, $str);
    $str = str_replace('6', NULL, $str);
    $str = str_replace('7', NULL, $str);
    $str = str_replace('8', NULL, $str);
    $str = str_replace('9', NULL, $str);
    $str = str_replace('A', NULL, $str);
    $str = str_replace('B', NULL, $str);
    $str = str_replace('C', NULL, $str);
    $str = str_replace('D', NULL, $str);
    $str = str_replace('E', NULL, $str);
    $str = str_replace('F', NULL, $str);
}

Open in new window

0
 
PhillipsPlasticsAuthor Commented:
That would make sense I guess I am not sure exactly how it redraws items?
Do you know of any way or library to use that mapping and redraw the items?
0
 
Ray PaseurCommented:
No, I do not know of a library.  I will tinker with it a little bit and see what burps out.  If there is anything interesting I will post here as soon as I get the results.
0
 
Ray PaseurCommented:
See http://www.laprbass.com/RAY_temp_philplastic_2.php where you can see "ABC" (you may need a fairly wide viewport).

I would like to think there is a tidier way to do this, but at least it recreates an image from the string of hex characters.

HTH, ~Ray
<?php // RAY_temp_philplastic_2.php
error_reporting(E_ALL);


function hextostr($x)
{
    $s='';
    foreach(explode(PHP_EOL,trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
    return($s);
}


$str = '3332320D0A340D0A333931203231340D0A333930203231340D0A333930203231340D0A333930203231340D0A333931203231340D0A333931203231350D0A333931203231370D0A333931203232300D0A333930203232340D0A333930203232390D0A333839203233360D0A333837203234330D0A333835203235320D0A333832203236310D0A333739203237310D0A333735203238320D0A333731203239320D0A333637203330330D0A333632203331330D0A333538203332330D0A333534203333320D0A333530203334300D0A333437203334380D0A333434203335340D0A333432203335390D0A333431203336340D0A333431203336370D0A333430203336390D0A333431203337310D0A333431203337310D0A333432203337310D0A333434203337300D0A333436203336390D0A333438203336360D0A333530203336320D0A333533203335370D0A333535203335310D0A333538203334350D0A333631203333380D0A333634203333310D0A333637203332340D0A333731203331360D0A333735203330380D0A333830203330300D0A333836203239310D0A333931203238310D0A333937203237310D0A343033203236310D0A343130203235300D0A343136203233390D0A343233203232380D0A343330203231380D0A343336203230390D0A343432203230300D0A343437203139340D0A343530203138380D0A343533203138350D0A343535203138320D0A343536203138300D0A343537203138300D0A343538203138300D0A343538203138310D0A343538203138340D0A343538203138380D0A343538203139350D0A343539203230330D0A343538203231330D0A343538203232350D0A343537203233380D0A343537203235320D0A343537203236360D0A343536203238310D0A343536203239350D0A343536203330390D0A343537203332330D0A343538203333370D0A343539203334390D0A343631203336300D0A343632203337300D0A343633203337390D0A343635203338370D0A343636203339330D0A343637203339380D0A343638203430320D0A343639203430350D0A343639203430360D0A343639203430360D0A343639203430360D0A333537203330310D0A333538203330300D0A333630203239390D0A333634203239380D0A333639203239360D0A333735203239340D0A333831203239330D0A333838203239330D0A333934203239320D0A343031203239320D0A343037203239320D0A343134203239320D0A343230203239320D0A343236203239310D0A343332203239300D0A343338203238380D0A343432203238360D0A343434203238360D0A343435203238350D0A343434203238350D0A363034203233300D0A363033203233300D0A363033203233300D0A363033203233310D0A363033203233320D0A363033203233350D0A363034203233390D0A363035203234340D0A363036203235310D0A363037203236300D0A363039203236390D0A363130203237390D0A363132203238380D0A363134203239380D0A363136203330370D0A363139203331350D0A363231203332330D0A363233203333300D0A363235203333360D0A363236203334310D0A363237203334350D0A363238203334390D0A363239203335310D0A363239203335330D0A363330203335350D0A363330203335360D0A363331203335360D0A363331203335360D0A363331203335360D0A363330203335340D0A363239203335310D0A363238203334380D0A363236203334330D0A363235203333370D0A363232203333300D0A363230203332320D0A363137203331320D0A363133203330320D0A363039203239300D0A363035203237370D0A363031203236340D0A353936203235320D0A353932203234310D0A353838203233300D0A353835203232310D0A353831203231320D0A353738203230350D0A353735203139380D0A353732203139330D0A353639203138380D0A353636203138330D0A353634203137380D0A353632203137340D0A353630203137310D0A353538203136370D0A353536203136340D0A353535203136320D0A353535203136300D0A353534203135390D0A353534203135390D0A353534203135380D0A353533203135380D0A353533203135390D0A353533203136300D0A353533203136310D0A353533203136320D0A353533203136330D0A353533203136350D0A353533203136360D0A353533203136380D0A353533203137300D0A353533203137310D0A353533203137320D0A353533203137330D0A353533203137340D0A353533203137350D0A353533203137350D0A353534203137360D0A353535203137370D0A353537203137370D0A353630203137370D0A353634203137360D0A353639203137350D0A353737203137340D0A353836203137330D0A353936203137320D0A363039203137320D0A363232203137320D0A363336203137330D0A363530203137360D0A363633203137390D0A363736203138340D0A363836203138390D0A363935203139350D0A373030203230310D0A373034203230370D0A373035203231340D0A373034203232300D0A373031203232360D0A363937203233320D0A363932203233370D0A363835203234320D0A363738203234360D0A363730203234390D0A363632203235310D0A363535203235310D0A363438203235310D0A363433203235300D0A363339203234390D0A363337203234380D0A363336203234370D0A363336203234360D0A363338203234340D0A363432203234340D0A363438203234340D0A363537203234340D0A363638203234360D0A363831203234390D0A363935203235320D0A373131203235370D0A373237203236330D0A373434203236390D0A373630203237360D0A373734203238320D0A373836203238390D0A373935203239360D0A383031203330330D0A383035203331300D0A383036203331360D0A383036203332330D0A383033203332390D0A373935203333360D0A373835203334330D0A373733203334380D0A373539203335310D0A373437203335330D0A373334203335330D0A373230203335320D0A373036203334390D0A363933203334360D0A363830203334320D0A363637203333370D0A363536203333330D0A363437203332380D0A363339203332350D0A363333203332310D0A363239203331390D0A363236203331370D0A363234203331350D0A363234203331340D0A363234203331330D0A363234203331320D0A363234203331320D0A363234203331320D0A393537203139390D0A393537203139380D0A393537203139360D0A393538203139330D0A393538203139300D0A393538203138380D0A393535203138370D0A393531203138370D0A393436203138390D0A393430203139320D0A393333203139370D0A393235203230340D0A393138203231320D0A393131203232310D0A393035203233310D0A393031203234320D0A383938203235330D0A383936203236350D0A383937203237360D0A383939203238370D0A393034203239370D0A393130203330360D0A393138203331330D0A393238203331390D0A393430203332330D0A393534203332360D0A393639203332370D0A393835203332370D0A31303031203332370D0A31303137203332360D0A31303332203332340D0A31303436203332320D0A31303539203332300D0A31303730203331370D0A31303830203331350D0A31303837203331330D0A31303933203331310D0A31303937203330390D0A31313030203330380D0A31313031203330360D0A31313031203330350D0A31313031203330340D0A31303939203330330D0A31303937203330330D0A31303935203330330D0A31303932203330330D0A31303839203330340D0A31303835203330350D0A31303832203330360D0A31303739203330370D0A31303736203330390D0A31303734203331300D0A31303733203331310D0A31303731203331310D0A31303730203331320D0A31303638203331320D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A31303637203331330D0A300D0A38380D0A3130380D0A3236320D0A00000000000000000000000000000000000000000000000000000000000000000000';

$new = rtrim($str, '0');
$nnn = hextostr($new);

// TIDY UP SOME OF THE CRYPTIC STUFF
$arr = explode(PHP_EOL, $nnn);
$arr = array_slice($arr, 0, 323);
$arr = array_slice($arr, 2);
foreach ($arr as $key => $val) $arr[$key] = trim($val);


// DETERMINE THE CANVAS CORNERS
$lo_x = 999999;
$hi_x = 0;
$lo_y = 999999;
$hi_y = 0;

foreach ($arr as $xy)
{
    $xyc = explode(' ', $xy);
    if ($xyc[0] < $lo_x) $lo_x = $xyc[0];
    if ($xyc[0] > $hi_x) $hi_x = $xyc[0];
    if ($xyc[1] < $lo_y) $lo_y = $xyc[1];
    if ($xyc[1] > $hi_y) $hi_y = $xyc[1];
}

// echo PHP_EOL . "THE CANVAS CORNERS ARE $lo_x, $lo_y AND $hi_x, $hi_y";


// FILL THE CANVAS WITH FALSE
$x = $lo_x;
while ($x <= $hi_x)
{
    $y = $lo_y;
    while ($y <= $hi_y)
    {
        $matrix[$x][$y] = FALSE;
        $y++;
    }
    $x++;
}


// FILL IN THE DARK PARTS WITH TRUE
foreach ($arr as $xy)
{
        $xyc = explode(' ', $xy);
        $matrix[$xyc[0]][$xyc[1]] = TRUE;
}


// CREATE AN IMAGE RESOURCE
$im = imagecreatetruecolor($hi_x, $hi_y);

// SET OUR COLORS
$bgcolor = imagecolorallocatealpha($im, 255, 255, 255,   0);
$pixels  = imagecolorallocatealpha($im,   1,   1,   1,   0);

// FILL THE BACKGROUND
imagefilledrectangle($im, 0, 0, $hi_x, $hi_y, $bgcolor);
imagealphablending($im, TRUE);
imagesavealpha($im, TRUE);

// FILL IN THE PIXELS, AS NEEDED
$x = $lo_x;
while ($x <= $hi_x)
{
    $y = $lo_y;
    while ($y <= $hi_y)
    {
        if ($matrix[$x][$y])
        {
            imagesetpixel($im, $x, $y, $pixels);
        }
        $y++;
    }
    $x++;
}


// PRODUCE A PNG IMAGE
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);

Open in new window

0
 
PhillipsPlasticsAuthor Commented:
Haha! Wow. I wonder if you limit the drawing area to the original size maybe it looks fluid?
0
 
Ray PaseurCommented:
That would seem feasible.  Just subtract the lowX and lowY values from each of the coordinates.
0
 
PhillipsPlasticsAuthor Commented:
Well it would appear I have lost you in that, I cannot figure out what exactly needs to be changed in order to draw a tighter image...
Also, Is there a limit as to how many points come across in a POST or in your script?  I appear to run out of drawing points after a certain amount of points have been drawn.
0
 
Ray PaseurCommented:
Not sure I understand all of the last post, but I'll try to help.  However if you do not understand the code I have posted here, it might be a good time to consider hiring a developer who can take this foundation and create a general-purpose solution for you.

If by saying to draw a tighter image you mean to make a smaller image, with lower X-Y dimensions, you can use the PHP function ImageCopyResampled() to proportionally resize the image.  Learn more about that here: http://php.net/manual/en/function.imagecopyresampled.php

Is there a limit to how many points come across?  I do not know; for me, this is external data that I got from you -- all I have is one test case.  I would need to see a great many more to begin to guess about things like that.  My code is based on what I was able to see in the data once we figured out that it was a hex character representation.    The array_slice statements may or may not be a good part of your final solution.  More tests will be needed.  My first suggestion would be to run a finger around the perimeter of the pad and look at that hex string.  Then do something like draw four circles in the corners of the pad and look at that hex string.  Things like that will tell a software developer a lot about the nature of the data.  So will documentation, and if you have access to it, I would definitely read it and share it with your developers.

appear to run out of drawing points -- I have no clue what that means.

converting the raw SigPlus data into something usuable on the server side of things - Yes, given the test data I had to work with, I think we have succeeded in doing that.

Best regards, ~Ray
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.