1Script file generated from LiVES
2
3<define>
4|1.8.3
5</define>
6
7<name>
8trim_frames
9</name>
10
11<version>
125
13</version>
14
15<author>
16Salsaman|
17</author>
18
19<description>
20Trim frames/Add Border|Trimming|0|1|
21</description>
22
23<requires>
24convert
25</requires>
26
27<params>
28xstart|_X Start|num0|0|0|10000|4|
29ystart|_Y Start|num0|0|0|10000|4|
30xend|_X End|num0|0|0|10000|4|
31yend|_Y End|num0|0|0|10000|4|
32kc|Keep _Centered|bool|0|
33w|_Width|num0|0|0|10000|4|
34h|_Height|num0|0|0|10000|4|
35bord|Add _Border|bool|0|
36offsx|_Offset X|num0|0|0|10000|
37offsy|_Offset Y|num0|0|0|10000|
38bordc|Border _Colour|colRGB24|0|0|0|
39</params>
40
41<param_window>
42layout|p0|p1|
43layout|p2|p3|
44layout|p4|
45special|framedraw|rectdemask|0|1|2|3|
46layout|hseparator|
47layout|p7|fill|p5|p6|
48layout|"Offset of frame within border"|p8|p9|
49special|aspect|5|6|
50</param_window>
51
52<properties>
530x0002
54</properties>
55
56<language_code>
570xF0
58</language_code>
59
60<pre>
61$antialias = &config_get("antialias", $configfile);
62$resize_ext = $out_ext;
63$resize_prefix = $out_prefix;
64$input_ext = $img_ext;
65$input_prefix = $img_prefix;
66
67$owidth = $width;
68$oheight = $height;
69
70$width = $p2 - $p0 + 1;
71$height = $p3 - $p1 + 1;
72
73if ($width < 1 || $width > $owidth) {
74   &sig_error("New width is invalid.");
75}
76if ($height < 1 || $height > $oheight) {
77   &sig_error("New height is invalid.");
78}
79
80
81if ($p7) {
82    $xwidth = $width;
83    $xheight = $height;
84    $width = $p5;
85    $height = $p6;
86    $cstring1 = &RGB24_to_string($p10_red, $p10_green, $p10_blue);
87    system("$convert_command -size $width\\!x$height\\! xc:$cstring1 $img_prefix" . "blank$img_ext");
88}
89</pre>
90
91<loop>
92&trim_frame($name, $owidth, $oheight, $p0, $p1, $width, $height);
93if ($p7) {
94    system("$composite_command -compose plus -dissolve 100 -geometry $xwidth\\!x$xheight\\!+$p8\\!+$p9\\! $out_prefix$out -size " .
95    "$width\\!x$height\\! $img_prefix" . "blank$img_ext $out");
96}
97</loop>
98
99<post>
100if (-f "blank$img_ext") {
101    unlink ("blank$img_ext");
102}
103</post>
104
105<onchange>
106init|$p0_max=$p2_max=$width-1;$p2=$width-1;$p0=0;
107init|$p1_max=$p3_max=$height-1;$p3=$height-1;$p1=0;
108init|$p5=$width;$p6=$height;
1090|$p8_max=$p5-$p2+$p0-1;
1100|if ($p4) {$p2=$width-1-$p0;$p8=int(($p5-$p0_max)/2.+$p0);}
1110|if ($p0>$p2) {$p2=$p0;}
1120|if ($p5==$width&&!$p4) {$p8=$p0;}
1130|$p5_min=$p2-$p0+1;
1141|$p9_max=$p6-$p3+$p1-1;
1151|if ($p4) {$p3=$height-1-$p1;$p9=int(($p6-$p1_max)/2.+$p1);}
1161|if ($p1>$p3) {$p3=$p1;}
1171|$p6_min=$p3-$p1+1;
1181|if ($p6==$height&&!$p4) {$p9=$p1;}
1192|$p8_max=$p5-$p2+$p0-1;
1202|if ($p4) {$p0=$width-1-$p2;$p8=int(($p5-$p0_max)/2.+$p0);}
1212|if ($p2<$p0) {$p0=$p2;}
1222|$p5_min=$p2-$p0+1;
1233|$p9_max=$p6-$p3+$p1-1;
1243|if ($p4) {$p1=$height-1-$p3;$p9=int(($p6-$p1_max)/2.+$p1);}
1253|if ($p3<$p1) {$p1=$p3;}
1263|$p6_min=$p3-$p1+1;
1275|$p8_max=$p5-$p2+$p0-1;
1285|if ($p4) {$p8=int(($p5-$p0_max)/2.+$p0);}
1295|$p7=1;
1306|$p9_max=$p6-$p3+$p1-1;
1316|if ($p4) {$p9=int(($p6-$p1_max)/2.+$p1);}
1326|$p7=1;
1334|if ($p4) {
1344| if ($p0<=$width/2) {
1354|     $p2=$width-1-$p0;
1364|    }
1374|  else {
1384|    $p0=$width-1-$p2;
1394|  }
1404| if ($p1<=$height/2) {
1414|    $p3=$height-1-$p1;
1424| }
1434|  else {
1444|    $p1=$height-1-$p3;
1454|  }
1464|}
147</onchange>
148