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