Exemplo n.º 1
0
 public function getSVG($post)
 {
     $art_id = $post['clipart_id'];
     $type = $post['file_type'];
     $medium = $post['medium'];
     $url = $post['url'];
     $file_name = $post['file_name'];
     $colors = $post['colors'];
     $file = $url . 'print/' . $file_name;
     include_once ROOT . DS . 'includes' . DS . 'libraries' . DS . 'svg.php';
     $data = array();
     $size = array();
     $size['height'] = 100;
     $size['width'] = 100;
     $xml = new svg($file, true);
     // get width, heigh of svg file
     $width = $xml->getWidth();
     $height = $xml->getHeight();
     // calculated width, height
     if ($width > $height) {
         $newHeight = $size['height'];
         $newWidth = $size['height'] / $height * $width;
     } else {
         $newWidth = $size['width'];
         $newHeight = $size['width'] / $width * $height;
     }
     // set width, height
     $xml->setWidth($newWidth . 'px');
     $xml->setHeight($newHeight . 'px');
     $data['content'] = $xml->asXML();
     $data['info']['type'] = 'svg';
     $data['info']['colors'] = json_decode($colors);
     $data['size']['width'] = $newWidth . 'px';
     $data['size']['height'] = $newHeight . 'px';
     return $data;
 }
Exemplo n.º 2
0
Arquivo: art.php Projeto: Nnamso/tbox
 public function getSVG()
 {
     $art_id = $this->input->post('clipart_id');
     $type = $this->input->post('file_type');
     $medium = $this->input->post('medium');
     $url = $this->input->post('url');
     $file_name = $this->input->post('file_name');
     $colors = $this->input->post('colors');
     $this->load->driver('cache');
     $fileCache = md5($file_name . $art_id);
     if ($data = $this->cache->file->get($fileCache)) {
         echo $data;
     } else {
         $file = $url . 'print/' . $file_name;
         $this->load->library('svg');
         $data = array();
         $size = array();
         $size['height'] = 100;
         $size['width'] = 100;
         $xml = new svg($file, true);
         // get width, heigh of svg file
         $width = $xml->getWidth();
         $height = $xml->getHeight();
         // calculated width, height
         if ($width > $height) {
             $newHeight = $size['height'];
             $newWidth = $size['height'] / $height * $width;
         } else {
             $newWidth = $size['width'];
             $newHeight = $size['width'] / $width * $height;
         }
         // set width, height
         $xml->setWidth($newWidth . 'px');
         $xml->setHeight($newHeight . 'px');
         $data['content'] = svgJs($xml->asXML());
         $data['info']['type'] = 'svg';
         $data['info']['colors'] = json_decode($colors);
         $data['size']['width'] = $newWidth . 'px';
         $data['size']['height'] = $newHeight . 'px';
         $this->cache->file->save($fileCache, json_encode($data), 3000000);
         echo json_encode($data);
     }
     exit;
 }