Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Gd
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
6
100.00% covered (success)
100.00%
1 / 1
 brightness
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 contrast
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 desaturate
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Image\Adjust;
15
16/**
17 * Adjust class for Gd
18 *
19 * @category   Pop
20 * @package    Pop\Image
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    3.4.0
25 */
26class Gd extends AbstractAdjust
27{
28
29    /**
30     * Adjust the image brightness
31     *
32     * @param  int $amount
33     * @return Gd
34     */
35    public function brightness($amount)
36    {
37        if ($this->hasImage()) {
38            imagefilter($this->image->getResource(), IMG_FILTER_BRIGHTNESS, $amount);
39        }
40        return $this;
41    }
42
43    /**
44     * Adjust the image contrast
45     *
46     * @param  int $amount
47     * @return Gd
48     */
49    public function contrast($amount)
50    {
51        if ($this->hasImage()) {
52            imagefilter($this->image->getResource(), IMG_FILTER_CONTRAST, (0 - $amount));
53        }
54        return $this;
55    }
56
57    /**
58     * Adjust the image desaturate
59     *
60     * @return Gd
61     */
62    public function desaturate()
63    {
64        if ($this->hasImage()) {
65            imagefilter($this->image->getResource(), IMG_FILTER_GRAYSCALE);
66        }
67        return $this;
68    }
69
70}