Passed
Push — master ( fa28f5...070d6c )
by Jens
02:40
created

Grayscale::Execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 2
b 0
f 1
1
<?php
2
/**
3
 * Resize
4
 *
5
 * @Author: Platform 0
6
 * @Package: JNS MVC
7
 */
8
 
9
namespace library\images\methods
10
{
11
	use \library\images\IMethod;
12
13
	class Grayscale extends IMethod
14
	{		
15
		public function Execute($imageResource)
16
		{			
17
			// Preserve transparency
18
			imagecolortransparent($imageResource, imagecolorallocatealpha($imageResource, 0, 0, 0, 127));
19
			imagealphablending($imageResource, false);
20
			imagesavealpha($imageResource, true);
21
			
22
			// Make grayscale
23
			imagefilter($imageResource, IMG_FILTER_GRAYSCALE);
24
			
25
			return $imageResource;
26
		}
27
	}
28
}