File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,16 @@ class CommandSet
21
21
* Trim surrounding space from the thumbnail. The top-left corner of the
22
22
* image is assumed to contain the background colour. To specify otherwise,
23
23
* pass either 'top-left' or 'bottom-right' as the $colourSource argument.
24
+ * For tolerance the euclidian distance between the colors of the reference pixel
25
+ * and the surrounding pixels is used. If the distance is within the
26
+ * tolerance they'll get trimmed. For a RGB image the tolerance would
27
+ * be within the range 0-442
24
28
*/
25
- public function trim ($ colourSource = null )
29
+ public function trim ($ colourSource = null , $ tolerance = null )
26
30
{
27
- $ this ->trim = 'trim ' . ($ colourSource ? ": $ colourSource " : '' );
31
+ $ this ->trim = 'trim ' ;
32
+ $ this ->trim .= $ colourSource ? ": $ colourSource " : '' ;
33
+ $ this ->trim .= $ tolerance ? ": $ tolerance " : '' ;
28
34
}
29
35
30
36
/**
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ public function testTrim()
28
28
array ('trim:bottom-right ' ),
29
29
$ commandSet ->toArray ()
30
30
);
31
+ $ commandSet ->trim ('top-left ' , 50 );
32
+ $ this ->assertEquals (
33
+ array ('trim:top-left:50 ' ),
34
+ $ commandSet ->toArray ()
35
+ );
31
36
}
32
37
33
38
public function testCrop ()
You can’t perform that action at this time.
0 commit comments