@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | * (ex: /src/var/www/wp-content/uploads/my-pic.png) |
36 | 36 | * @return bool true if everything went fine, false otherwise |
37 | 37 | */ |
38 | - function run($load_filename, $save_filename){ |
|
39 | - $input = self::image_create( $load_filename ); |
|
40 | - list( $width, $height ) = getimagesize( $load_filename ); |
|
41 | - $output = imagecreatetruecolor( $width, $height ); |
|
42 | - $c = self::hexrgb( $this->color ); |
|
43 | - $color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] ); |
|
44 | - imagefilledrectangle( $output, 0, 0, $width, $height, $color ); |
|
45 | - imagecopy( $output, $input, 0, 0, 0, 0, $width, $height ); |
|
46 | - imagejpeg( $output, $save_filename ); |
|
38 | + function run($load_filename, $save_filename) { |
|
39 | + $input = self::image_create($load_filename); |
|
40 | + list($width, $height) = getimagesize($load_filename); |
|
41 | + $output = imagecreatetruecolor($width, $height); |
|
42 | + $c = self::hexrgb($this->color); |
|
43 | + $color = imagecolorallocate($output, $c['red'], $c['green'], $c['blue']); |
|
44 | + imagefilledrectangle($output, 0, 0, $width, $height, $color); |
|
45 | + imagecopy($output, $input, 0, 0, 0, 0, $width, $height); |
|
46 | + imagejpeg($output, $save_filename); |
|
47 | 47 | return true; |
48 | 48 | } |
49 | 49 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * @return resource an image identifier representing the image obtained from the given filename |
52 | 52 | * will return the same data type regardless of whether the source is gif or png |
53 | 53 | */ |
54 | - function image_create( $filename, $ext = 'auto' ) { |
|
54 | + function image_create($filename, $ext = 'auto') { |
|
55 | 55 | if ( $ext == 'auto' ) { |
56 | 56 | $ext = wp_check_filetype($filename); |
57 | - if (isset($ext['ext'])) { |
|
57 | + if ( isset($ext['ext']) ) { |
|
58 | 58 | $ext = $ext['ext']; |
59 | 59 | } |
60 | 60 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | if ( $ext == 'png' ) { |
66 | 66 | return imagecreatefrompng($filename); |
67 | 67 | } |
68 | - if ( $ext == 'jpg' || $ext == 'jpeg') { |
|
68 | + if ( $ext == 'jpg' || $ext == 'jpeg' ) { |
|
69 | 69 | return imagecreatefromjpeg($filename); |
70 | 70 | } |
71 | - throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext); |
|
71 | + throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: ' . $ext); |
|
72 | 72 | } |
73 | 73 | } |