public static function getInstance($x, $y, $id, $filename, $embed = true)
 {
     $image = new SVGImage('<image></image>');
     $image->setX($x);
     $image->setY($y);
     $image->setId($id);
     $image->setImage($filename, $embed);
     return $image;
 }
示例#2
0
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, access
 *   http://www.fsf.org/licensing/licenses/lgpl.html or write to the
 *   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
require_once "../svglib/svglib.php";
//get one SVG with one image
$svg = SVGDocument::getInstance('resource/image.svg');
//convert the image to SVGImage object
$embed = $svg->getElementById('stickEmbed');
//convert the element to an image
$image = @new SVGImage($embed->asXML());
//export the image to a file, if is png
if ($image->getImageData()->mime == 'image/png') {
    file_put_contents('output/test.png', $image->getImage());
    //chmod( 'output/test.png' , '0777');
}
//add a new image to SVG (embed)
$svg->addShape(SVGImage::getInstance(50, 50, 'myImage', 'resource/stick.png'));
//make the output to browser
$svg->output();
示例#3
0
 /**
  * Do the actual processing to generate the SVG
  * image based on the user input. Used both when 
  * displaying the image to the browser and when
  * saving the image to the disk.
  * 
  * @return bool
  */
 protected function processImage()
 {
     $candidateImage = GRAPHIC_MATERIAL_DIR . '/' . strtolower(get_called_class()) . '_candidate_croped.png';
     $this->data->shapeName = isset($_REQUEST['data']['shapeName']) ? filter_var($_REQUEST['data']['shapeName'], FILTER_SANITIZE_STRING) : null;
     $path = WPMU_PLUGIN_DIR . "/img/graphic_material/{$this->data->shapeName}.svg";
     if (!empty($this->data->shapeName)) {
         if (file_exists($path)) {
             $this->finalImage = SVGDocument::getInstance($path, 'CampanhaSVGDocument');
             $candidateImage = SVGImage::getInstance(0, 0, 'candidateImage', $candidateImage);
             $this->finalImage->prependImage($candidateImage);
             $this->formatShape();
             $this->formatText();
             return true;
         } else {
             throw new Exception('Não foi possível encontrar o arquivo com a forma.');
         }
     }
     return false;
 }