public function get_image($signature_id)
 {
     $signature = $this->get($signature_id);
     $this->load->helper('signature');
     /*
      *  @param string|array $json
      *  @param array $options OPTIONAL; the options for image creation
      *    imageSize => array(width, height)
      *    bgColour => array(red, green, blue) | transparent
      *    penWidth => int
      *    penColour => array(red, green, blue)
      *    drawMultiplier => int
      */
     $image = sigJsonToImage($signature->signature_text, array());
     $temp_img = '/tmp/sig_png_' . rand(0, 543435) . '.png';
     imagepng($image, $temp_img);
     return $temp_img;
 }
示例#2
0
if ($division == "") {
    $division = "X";
}
if ($oppositionid == "") {
    $oppositionid = 0;
}
if ($hometeamid == "") {
    $hometeamid = 0;
}
if ($leaguecup == "") {
    $leaguecup = "L";
}
try {
    $img = null;
    if (isset($_POST['output']) && $_POST['output'] != "") {
        $img = sigJsonToImage($_POST['output']);
    } else {
        // Create the image
        $img = imagecreatetruecolor(400, 30);
        // Create some colors
        $white = imagecolorallocate($img, 255, 255, 255);
        $grey = imagecolorallocate($img, 128, 128, 128);
        $black = imagecolorallocate($img, 0, 0, 0);
        imagefilledrectangle($img, 0, 0, 399, 29, $white);
        // The text to draw
        $text = $_POST['name'];
        // Replace path by your own font path
        $font = 'build/journal.ttf';
        // Add some shadow to the text
        imagettftext($img, 20, 0, 11, 21, $grey, $font, $text);
        // Add the text
示例#3
0
<?php

require_once './signature-to-image.php';
$json = $_POST['output'];
$img = sigJsonToImage($json);
$filename = 'signature' . time() . '.png';
imagepng($img, './images/' . $filename);
echo $filename;
示例#4
0
 /**
  * Save the signature to an image
  *
  * @return  void
  */
 public function onAjax_signature_to_image()
 {
     $input = $this->app->input;
     $this->setId($input->getInt('element_id'));
     $this->loadMeForAjax();
     $this->getElement();
     $params = $this->getParams();
     $digsig_width = (int) $params->get('digsig_list_width', '200');
     $digsig_height = (int) $params->get('digsig_list_height', '75');
     $this->lang->load('com_fabrik.plg.element.fabrikdigsig', JPATH_ADMINISTRATOR);
     $url = 'index.php';
     if (!$this->canView()) {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_DIGSIG_NO_PERMISSION'));
         $this->app->redirect($url);
         exit;
     }
     $rowId = $input->get('rowid', '', 'string');
     if (empty($rowId)) {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_FDIGSIG_NO_SUCH_FILE'));
         $this->app->redirect($url);
         exit;
     }
     $listModel = $this->getListModel();
     $row = $listModel->getRow($rowId, false);
     if (empty($row)) {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_DIGSIG_NO_SUCH_FILE'));
         $this->app->redirect($url);
         exit;
     }
     $elName = $this->getFullName(true, false);
     $json_sig = $row->{$elName};
     require JPATH_SITE . '/plugins/fabrik_element/digsig/libs/signature-to-image/signature-to-image.php';
     $opts = array('imageSize' => array($digsig_width, $digsig_height));
     $fileContent = sigJsonToImage($json_sig, $opts);
     if (!empty($fileContent)) {
         ob_start();
         imagepng($fileContent);
         $img = ob_get_contents();
         ob_end_clean();
         // Some time in the past
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
         header('Accept-Ranges: bytes');
         header('Content-Length: ' . strlen($img));
         header('Content-Type: ' . 'image/png');
         // Serve up the file
         echo $img;
         // And we're done.
         exit;
     } else {
         $this->app->enqueueMessage(FText::_('PLG_ELEMENT_DIGSIG_NO_SUCH_FILE'));
         $this->app->redirect($url);
         exit;
     }
 }
示例#5
0
<?php

require_once '../../signature-to-image.php';
$img = sigJsonToImage(file_get_contents('sig-output.json'));
// Save to file
//imagepng($img, 'signature.png');
// Output to browser
header('Content-Type: image/png');
imagepng($img);
// Destroy the image in memory when complete
imagedestroy($img);
示例#6
0
 private function _ProcessSignature()
 {
     if (Config::GetInstance()->GetRulePropertyByName('sigpad', 'sigpad') != 'enable') {
         return;
     }
     $dest = Config::GetInstance()->GetStorageFolder(1);
     if (!is_dir($dest) && !mkdir($dest, 0755)) {
         $this->errors[] = array("err" => _T('Could not create file upload directory "%s" for the signature', $dest));
         return;
     }
     $prefix = MessagePostMerger::GetInstance()->SubstituteFieldNames($this->post['sigpad']['sigpad-prefix'], false);
     $filename = $prefix . '_' . makeRandomString() . '.png';
     include 'fbapp/inc/signature-to-image.php';
     $json = $this->post['sigpad']['sigpad-output'];
     // Set drawMultiplier to 4 to avoid memory issues.
     $img = sigJsonToImage($json, array('imageSize' => array($this->post['sigpad']['sigpad-width'], $this->post['sigpad']['sigpad-height']), 'drawMultiplier' => 4));
     imagepng($img, $dest . $filename);
     imagedestroy($img);
     // store the name in post
     $this->post['sigpad'] = $filename;
     // add the file to the uploads array
     $this->uploads[] = array('orgname' => $filename, 'storedname' => $filename, 'fieldname' => 'sigpad');
     if ($this->mysql) {
         $this->mysql->UpdatePost($this->post);
     }
     if ($this->sqlite) {
         $this->sqlite->UpdatePost($this->post);
     }
     if ($this->csv) {
         $this->csv->UpdatePost($this->post);
     }
 }