elkarte /
Elkarte
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file deals with creating an image file based on supplied text. For example |
||
| 5 | * the attachment not found image |
||
| 6 | * |
||
| 7 | * TrueType fonts supplied by www.LarabieFonts.com |
||
| 8 | * |
||
| 9 | * @package ElkArte Forum |
||
| 10 | * @copyright ElkArte Forum contributors |
||
| 11 | * @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
||
| 12 | * |
||
| 13 | * @version 2.0 dev |
||
| 14 | * |
||
| 15 | */ |
||
| 16 | |||
| 17 | namespace ElkArte\Graphics; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Class TextImage |
||
| 21 | * |
||
| 22 | * Base class for text to image functions |
||
| 23 | * |
||
| 24 | * @package ElkArte\Graphics |
||
| 25 | */ |
||
| 26 | class TextImage extends Image |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Image constructor. |
||
| 30 | * |
||
| 31 | * @param string $_text |
||
| 32 | * @param bool $force_gd |
||
| 33 | */ |
||
| 34 | public function __construct(protected $_text, $force_gd = false) |
||
| 35 | { |
||
| 36 | $this->_force_gd = $force_gd; |
||
| 37 | |||
| 38 | 2 | // Determine and set what image library we will use |
|
| 39 | try |
||
| 40 | 2 | { |
|
| 41 | 2 | $this->setManipulator(); |
|
| 42 | } |
||
| 43 | catch (\Exception) |
||
| 44 | { |
||
| 45 | // Nothing to do |
||
| 46 | 2 | } |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Do nothing |
||
| 51 | */ |
||
| 52 | 2 | public function loadImage() |
|
| 53 | { |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Do nothing |
||
| 58 | * |
||
| 59 | * @param string $source |
||
| 60 | */ |
||
| 61 | public function setSource($source): void |
||
|
0 ignored issues
–
show
|
|||
| 62 | { |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Do nothing |
||
| 67 | * |
||
| 68 | * @return bool |
||
| 69 | */ |
||
| 70 | public function isWebAddress() |
||
| 71 | { |
||
| 72 | return false; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Simple function to generate an image containing some text. |
||
| 77 | * It uses preferentially ImageMagick if present, otherwise GD. |
||
| 78 | * Font and size are fixed. |
||
| 79 | * |
||
| 80 | * @param int $width Width of the final image |
||
| 81 | * @param int $height Height of the image |
||
| 82 | * @param string $format Type of the image (valid types are png, jpeg, gif) |
||
| 83 | * |
||
| 84 | * @return bool|string The image or false if neither ImageMagick nor GD are found |
||
| 85 | */ |
||
| 86 | public function generate($width = 100, $height = 75, $format = 'png') |
||
| 87 | { |
||
| 88 | $valid_formats = ['jpeg', 'png', 'gif']; |
||
| 89 | if (!in_array($format, $valid_formats)) |
||
| 90 | { |
||
| 91 | $format = 'png'; |
||
| 92 | } |
||
| 93 | 2 | ||
| 94 | return $this->_manipulator->generateTextImage($this->_text, $width, $height, $format); |
||
| 95 | 2 | } |
|
| 96 | 2 | ||
| 97 | /** |
||
| 98 | * Do nothing |
||
| 99 | * |
||
| 100 | * @return int |
||
| 101 | 2 | */ |
|
| 102 | public function getFilesize() |
||
| 103 | { |
||
| 104 | return 0; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Do nothing |
||
| 109 | * |
||
| 110 | * @return bool |
||
| 111 | */ |
||
| 112 | public function isImage() |
||
| 113 | { |
||
| 114 | return true; |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Do nothing |
||
| 119 | * |
||
| 120 | * @param int $max_width allowed width |
||
| 121 | * @param int $max_height allowed height |
||
| 122 | * @param string $dstName name to save |
||
| 123 | * @param string $format image format to save the thumbnail |
||
| 124 | * @param null|bool $force if forcing the image resize to scale up, the default action |
||
| 125 | */ |
||
| 126 | public function createThumbnail($max_width, $max_height, $dstName = '', $format = '', $force = null) |
||
| 127 | { |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Do nothing |
||
| 132 | */ |
||
| 133 | public function autoRotate() |
||
| 134 | { |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Do nothing |
||
| 139 | * |
||
| 140 | * @param int $max_width The maximum allowed width |
||
| 141 | * @param int $max_height The maximum allowed height |
||
| 142 | * @param bool $force_resize Always resize the image (force scale up) |
||
| 143 | * @param bool $strip Allow IM to remove exif data as GD always will |
||
| 144 | * |
||
| 145 | * @return bool Always returns true. |
||
| 146 | */ |
||
| 147 | public function resizeImage($max_width, $max_height, $strip = false, $force_resize = true, $thumbnail = false) |
||
| 148 | { |
||
| 149 | return true; |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Do nothing |
||
| 154 | * |
||
| 155 | * @param string $file_name name to save the image to |
||
| 156 | * @param int $preferred_format what format to save the image |
||
| 157 | * @param int $quality some formats require we provide a compression quality |
||
| 158 | * |
||
| 159 | * @return bool Always returns true. |
||
| 160 | */ |
||
| 161 | public function saveImage($file_name = '', $preferred_format = IMAGETYPE_JPEG, $quality = 85) |
||
| 162 | { |
||
| 163 | return true; |
||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Do nothing |
||
| 168 | */ |
||
| 169 | public function __destruct() |
||
| 170 | { |
||
| 171 | } |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Do nothing |
||
| 175 | 2 | * |
|
| 176 | * @return bool Always returns true. |
||
| 177 | 2 | */ |
|
| 178 | public function reEncodeImage() |
||
| 179 | { |
||
| 180 | return true; |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Do nothing |
||
| 185 | * |
||
| 186 | * @return array |
||
| 187 | */ |
||
| 188 | public function getSize(): array |
||
| 189 | { |
||
| 190 | return $this->_manipulator->imageDimensions; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Do nothing |
||
| 195 | * |
||
| 196 | * @return bool Always returns true. |
||
| 197 | */ |
||
| 198 | public function checkImageContents() |
||
| 199 | { |
||
| 200 | return true; |
||
| 201 | } |
||
| 202 | } |
||
| 203 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.