PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.4 3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 All 262 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Gd / Driver.php

Driver.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/intervention/image/src/Intervention/Image/Gd/Driver.php

90 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image\Gd;
4
5 use Intervention\Image\Exception\NotSupportedException;
6 use Intervention\Image\Image;
7
8 class Driver extends \Intervention\Image\AbstractDriver
9 {
10 /**
11 * Creates new instance of driver
12 *
13 * @param Decoder $decoder
14 * @param Encoder $encoder
15 */
16 public function __construct(Decoder $decoder = null, Encoder $encoder = null)
17 {
18 if ( ! $this->coreAvailable()) {
19 throw new NotSupportedException(
20 "GD Library extension not available with this PHP installation."
21 );
22 }
23
24 $this->decoder = $decoder ? $decoder : new Decoder;
25 $this->encoder = $encoder ? $encoder : new Encoder;
26 }
27
28 /**
29 * Creates new image instance
30 *
31 * @param int $width
32 * @param int $height
33 * @param mixed $background
34 * @return \Intervention\Image\Image
35 */
36 public function newImage($width, $height, $background = null)
37 {
38 // create empty resource
39 $core = imagecreatetruecolor($width, $height);
40 $image = new Image(new static, $core);
41
42 // set background color
43 $background = new Color($background);
44 imagefill($image->getCore(), 0, 0, $background->getInt());
45
46 return $image;
47 }
48
49 /**
50 * Reads given string into color object
51 *
52 * @param string $value
53 * @return AbstractColor
54 */
55 public function parseColor($value)
56 {
57 return new Color($value);
58 }
59
60 /**
61 * Checks if core module installation is available
62 *
63 * @return boolean
64 */
65 protected function coreAvailable()
66 {
67 return (extension_loaded('gd') && function_exists('gd_info'));
68 }
69
70 /**
71 * Returns clone of given core
72 *
73 * @return mixed
74 */
75 public function cloneCore($core)
76 {
77 $width = imagesx($core);
78 $height = imagesy($core);
79 $clone = imagecreatetruecolor($width, $height);
80 imagealphablending($clone, false);
81 imagesavealpha($clone, true);
82 $transparency = imagecolorallocatealpha($clone, 0, 0, 0, 127);
83 imagefill($clone, 0, 0, $transparency);
84
85 imagecopy($clone, $core, 0, 0, 0, 0, $width, $height);
86
87 return $clone;
88 }
89 }
90