public function testBase30_to_Native_Full()
 {
     $converter = new jSignature_Tools_Base30();
     $signature = "3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4";
     $expected = array(array('x' => array(100, 101, 104, 99, 104), 'y' => array(50, 52, 56, 50, 44)), array('x' => array(50, 51, 48), 'y' => array(100, 102, 98)));
     $actual = $converter->Base64ToNative($signature);
     $this->assertEquals($expected, $actual);
 }
 public static function signToImage($dbData, $outFile)
 {
     // Get signature string from _POST
     $data = str_replace('data:image/jsignature;base30,', '', $dbData);
     // Create jSignature object
     $signature = new \jSignature_Tools_Base30();
     // Decode base30 format
     $a = $signature->Base64ToNative($data);
     // Create a image
     $im = imagecreatetruecolor(640, 280);
     // Save transparency for PNG
     imagesavealpha($im, true);
     // Fill background with transparency
     $trans_colour = imagecolorallocatealpha($im, 255, 255, 255, 127);
     imagefill($im, 0, 0, $trans_colour);
     // Set pen thickness
     imagesetthickness($im, 5);
     // Set pen color to black
     $black = imagecolorallocate($im, 0, 0, 0);
     // Loop through array pairs from each signature word
     for ($i = 0; $i < count($a); $i++) {
         // Loop through each pair in a word
         for ($j = 0; $j < count($a[$i]['x']); $j++) {
             // Make sure we are not on the last coordinate in the array
             if (!isset($a[$i]['x'][$j]) or !isset($a[$i]['x'][$j + 1])) {
                 break;
             }
             // Draw the line for the coordinate pair
             imageline($im, $a[$i]['x'][$j], $a[$i]['y'][$j], $a[$i]['x'][$j + 1], $a[$i]['y'][$j + 1], $black);
         }
     }
     if (file_exists($outFile)) {
         unlink($outFile);
     }
     // Save image to a folder
     if (!imagepng($im, $outFile)) {
         // Removing $filename will output to browser instead of saving
         die("!! Error exporting signature !!");
     }
     // Clean up
     imagedestroy($im);
 }