-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathimageEmbroidery.php
More file actions
36 lines (34 loc) · 890 Bytes
/
imageEmbroidery.php
File metadata and controls
36 lines (34 loc) · 890 Bytes
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
<?php
require_once('embroidery2image.php');
require_once('embroidery2svg.php');
function imageEmbroidery($embroidery,$base=false,$scale_post=1,$scale_pre=false) {
$im=embroidery2image($embroidery,$scale_post,$scale_pre);
if($base){
// Save png
imagepng($im,$base.'.png');
// Optimize png
exec('optipng '.escapeshellcmd($base.'.png'));
// Save svg
$svg=embroidery2svg($embroidery,$scale_post);
file_put_contents($base.'.svg',$svg);
}else{
// Output image
header('Content-type: image/png');
imagepng($im);
}
imagedestroy($im);
}
function getEmbroideryInformation($embroidery){
$info=array(
'width'=>$embroidery->imageWidth,
'height'=>$embroidery->imageHeight,
'stitches'=>0,
'colors_pes'=>array(),
);
foreach($embroidery->blocks as $block){
$info['stitches']+=$block->stitchesTotal;
$info['colors_pes'][]=$block->colorIndex;
}
return($info);
}
?>