Blame view

class_mcInkscape.inc.php 2.51 KB
sn committed
1 2 3 4 5 6 7 8
<?php

class mcInkscape {
	
	/**
	 * 
	 * @param string $param_svgFileString
	 */
sn committed
9 10 11 12 13 14 15 16 17
	public static function svgToPng($param_input_filename, array $param_outputfile=null, array $param_quality =null) {
		mcFile::manipulateOutputfileArray($param_outputfile, $param_input_filename);
		if(!$param_outputfile['filename']) {
			if(!$param_outputfile['filenameextension']) {
				$param_outputfile['filenameextension'] = '.png';
			}
			$outfile = mcFile::createTmpFile($param_outputfile);
		} else {
			$outfile = $param_outputfile['filename'];
sn committed
18
		}
sn committed
19 20 21 22

		if(!$param_quality['dpi']) {
			$param_quality['dpi'] = 90;
		}		
sn committed
23
		
sn committed
24
		$order = "inkscape $param_input_filename --export-dpi=".$param_quality['dpi']." -e $outfile";
sn committed
25
//		D::ulli('$'.$order);
sn committed
26
		$shell_exec = shell_exec($order);	
sn committed
27

sn committed
28
		return $outfile;
sn committed
29
	}
sn committed
30 31 32 33 34

	/**
	 * 
	 * @param string $param_svgFileString
	 */
sn committed
35 36 37 38 39 40 41 42 43 44 45
	public static function svgToPdf($param_input_filename, array $param_outputfile=null, array $param_quality =null) {
		mcFile::manipulateOutputfileArray($param_outputfile, $param_input_filename);
		if(!$param_outputfile['filename']) {
			if(!$param_outputfile['filenameextension']) {
				$param_outputfile['filenameextension'] = '.pdf';
			}
				
			$outfile = mcFile::createTmpFile($param_outputfile);
		} else {
			$outfile = $param_outputfile['filename'];
		}
sn committed
46
		
sn committed
47 48
		if(!$param_quality['DPI']) {
			$param_quality['DPI'] = 90;
sn committed
49
		}
sn committed
50 51 52
		if(!$param_quality['PDF_VERSION']) {
			$param_quality['PDF_VERSION'] = 1.4;
		}		
sn committed
53
		
sn committed
54 55
		
		$order = "inkscape $param_input_filename --export-dpi=".$param_quality['dpi']."  --export-pdf=$outfile";
sn committed
56
//		D::ulli('$'.$order);
sn committed
57
		$shell_exec = shell_exec($order);	
sn committed
58

sn committed
59
		return $outfile;
sn committed
60 61
	}
	
sn committed
62 63 64 65 66 67 68
	
	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);
	}
	
sn committed
69
	
sn committed
70 71 72 73 74 75 76 77 78 79
	public static function inkscapeSvgToNormalSvg($param_input_filename, array $param_outputfile=null) {
		mcFile::manipulateOutputfileArray($param_outputfile, $param_input_filename);
		if(!$param_outputfile['filename']) {
			if(!$param_outputfile['filenameextension']) {
				$param_outputfile['filenameextension'] = '.svg';
			}
				
			$outfile = mcFile::createTmpFile($param_outputfile);
		} else {
			$outfile = $param_outputfile['filename'];
sn committed
80 81
		}
 	
sn committed
82
		$inkscape_order = "inkscape -T ".$param_input_filename." -l ".$outfile."  ";
sn committed
83
		$shell_exec = shell_exec($inkscape_order);	
sn committed
84
//		D::show($shell_exec, $inkscape_order);
sn committed
85

sn committed
86
		return $outfile;		
sn committed
87 88
		
	}
sn committed
89 90 91
}

?>