class_mcInkscape.inc.php 1.21 KB
<?php

class mcInkscape {
	
	/**
	 * 
	 * @param string $param_svgFileString
	 */
	public static function svgToPng($param_in_svg, $param_out_png=false) {
		
		if($param_out_png === false) {
			$param_out_png = tempnam("/tmp", "mcInkscape_");
			$tmp_png = $param_out_png.'.png';
			mcFile::rename($param_out_png, $tmp_png);
			$param_out_png = $tmp_png;
		}
		
		$inkscape_order = "inkscape $param_in_svg -e $param_out_png";
		$shell_exec = shell_exec($inkscape_order);	

		return $param_out_png;
	}

	/**
	 * 
	 * @param string $param_svgFileString
	 */
	public static function svgToPdf($param_in_svg, $param_out_pdf=false) {
		
		if($param_out_pdf === false) {
			$param_out_pdf = tempnam("/tmp", "mcInkscape_");
			$tmp_png = $param_out_pdf.'.pdf';
			mcFile::rename($param_out_pdf, $tmp_png);
			$param_out_pdf = $tmp_png;
		}
		
		$inkscape_order = "inkscape $param_in_svg -A $param_out_pdf";
		$shell_exec = shell_exec($inkscape_order);	

		return $param_out_pdf;
	}
	
	
	public static function svgToJpg($param_in_svg, $param_out_jpg=false, $param_quality=100) {
		$new_png = mcInkscape::svgToPng($param_in_svg);
//		D::li('1.1 $new_png: '.$new_png);
		return mcImage::pngToJpg($new_png, $param_out_jpg, $param_quality);
	}
	
}

?>