-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGd.php
104 lines (95 loc) · 2.46 KB
/
Gd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* Pop PHP Framework (https://www.popphp.org/)
*
* @link https://github.com/popphp/popphp-framework
* @author Nick Sagona, III <dev@noladev.com>
* @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC.
* @license https://www.popphp.org/license New BSD License
*/
/**
* @namespace
*/
namespace Pop\Image;
/**
* Image Gd factory class
*
* @category Pop
* @package Pop\Image
* @author Nick Sagona, III <dev@noladev.com>
* @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC.
* @license https://www.popphp.org/license New BSD License
* @version 4.1.1
*/
class Gd
{
/**
* Get the available image adapters
*
* @return array
*/
public static function getAvailableAdapters(): array
{
return Image::getAvailableAdapters();
}
/**
* Determine if the GD adapter is available
*
* @return bool
*/
public static function isAvailable(): bool
{
return Image::isAvailable('gd');
}
/**
* Load the image resource from the existing image file into a Gd object
*
* @param string $image
* @return Adapter\Gd
*/
public static function load(string $image): Adapter\Gd
{
return new Adapter\Gd($image);
}
/**
* Load the image resource from data into a Gd object
*
* @param string $data
* @param ?string $name
* @throws Adapter\Exception
* @return Adapter\Gd
*/
public static function loadFromString(string $data, ?string $name = null): Adapter\Gd
{
$gd = new Adapter\Gd();
$gd->loadFromString($data, $name);
return $gd;
}
/**
* Create a new image resource and load it into a Gd object
*
* @param int $width
* @param int $height
* @param ?string $image
* @return Adapter\Gd
*/
public static function create(int $width, int $height, ?string $image = null): Adapter\Gd
{
return new Adapter\Gd($width, $height, $image);
}
/**
* Create a new indexed image resource and load it into a Gd object
*
* @param int $width
* @param int $height
* @param ?string $image
* @throws Adapter\Exception
* @return Adapter\Gd
*/
public static function createIndex(int $width, int $height, ?string $image = null): Adapter\Gd
{
$gd = new Adapter\Gd();
$gd->createIndex($width, $height, $image);
return $gd;
}
}