class_mcInkscape.inc.php
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?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);
}
}
class mcCairoSvg {
/**
*
* @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 = "cairosvg.sh $param_in_svg $param_out_pdf";
$shell_exec = shell_exec($inkscape_order);
D::show($shell_exec, $inkscape_order);
return $param_out_pdf;
}
}
?>