@@ -128,11 +128,11 @@ public static function make(array $waterOptions = [], array $thumbOptions = [])
128128 */
129129 public function __construct (array $ waterOptions = [], array $ thumbOptions = [])
130130 {
131- if (!extension_loaded ('gd ' )) {
131+ if (!\ extension_loaded ('gd ' )) {
132132 throw new ExtensionMissException ('This tool required extension [gd]. ' );
133133 }
134134
135- $ this ->waterOptions ['fontFile ' ] = dirname (__DIR__ ) . '/resources/fonts/Montserrat-Bold.ttf ' ;
135+ $ this ->waterOptions ['fontFile ' ] = \ dirname (__DIR__ ) . '/resources/fonts/Montserrat-Bold.ttf ' ;
136136
137137 $ this ->setWaterOptions ($ waterOptions )->setThumbOptions ($ thumbOptions );
138138
@@ -167,7 +167,7 @@ public function watermark($img, $outPath = '', $pos = '', $waterImg = '', $alpha
167167
168168 $ imgInfo = pathinfo ($ img );
169169 $ imgType = $ this ->_handleImageType ($ imgInfo ['extension ' ]);
170- $ outPath = $ outPath ?: ($ this ->waterOptions ['path ' ] ?: dirname ($ img ));
170+ $ outPath = $ outPath ?: ($ this ->waterOptions ['path ' ] ?: \ dirname ($ img ));
171171 $ pos = $ pos ?: $ this ->waterOptions ['pos ' ];
172172 $ alpha = $ alpha ?: $ this ->waterOptions ['alpha ' ];
173173 $ waterImg = $ waterImg ?: $ this ->waterOptions ['img ' ];
@@ -192,7 +192,7 @@ public function watermark($img, $outPath = '', $pos = '', $waterImg = '', $alpha
192192 }
193193
194194 // create water image resource
195- $ resWaterImg = call_user_func ("imagecreatefrom {$ waterImgType }" , $ waterImg );
195+ $ resWaterImg = \ call_user_func ("imagecreatefrom {$ waterImgType }" , $ waterImg );
196196 } else {
197197 //水印文字
198198 $ text = $ text ?: $ this ->waterOptions ['text ' ];
@@ -201,7 +201,7 @@ public function watermark($img, $outPath = '', $pos = '', $waterImg = '', $alpha
201201 throw new InvalidConfigException ('请配置正确的水印文字资源路径 ' );
202202 }
203203
204- if (!$ text || strlen ($ this ->waterOptions ['fontColor ' ]) !== 6 ) {
204+ if (!$ text || \ strlen ($ this ->waterOptions ['fontColor ' ]) !== 6 ) {
205205 throw new InvalidConfigException ('The watermark font color length must equal to 6. ' );
206206 }
207207
@@ -251,7 +251,7 @@ public function watermark($img, $outPath = '', $pos = '', $waterImg = '', $alpha
251251 } elseif ($ imgType === self ::IMAGE_PNG ) {
252252 imagepng ($ resImg , $ outFile , ceil ($ this ->waterOptions ['quality ' ] / 10 ));
253253 } else {
254- call_user_func ("image {$ imgType }" , $ resImg , $ outFile );
254+ \ call_user_func ("image {$ imgType }" , $ resImg , $ outFile );
255255 }
256256
257257 imagedestroy ($ resImg );
@@ -308,7 +308,7 @@ public function thumbnail($img, $outPath = '', $outFilename = '', $thumbWidth =
308308 $ thumbType = $ thumbType ?: $ this ->thumbOptions ['type ' ];
309309 $ thumbWidth = $ thumbWidth ?: $ this ->thumbOptions ['width ' ];
310310 $ thumbHeight = $ thumbHeight ?: $ this ->thumbOptions ['height ' ];
311- $ outPath = $ outPath ?: ($ this ->thumbOptions ['path ' ] ?: dirname ($ img ));
311+ $ outPath = $ outPath ?: ($ this ->thumbOptions ['path ' ] ?: \ dirname ($ img ));
312312
313313 //获得图像信息
314314 list ($ imgWidth , $ imgHeight ) = getimagesize ($ img );
@@ -319,7 +319,7 @@ public function thumbnail($img, $outPath = '', $outFilename = '', $thumbWidth =
319319
320320 //原始图像资源
321321 // imagecreatefromgif() imagecreatefrompng() imagecreatefromjpeg() imagecreatefromwbmp()
322- $ resImg = call_user_func ("imagecreatefrom {$ imgType }" , $ img );
322+ $ resImg = \ call_user_func ("imagecreatefrom {$ imgType }" , $ img );
323323
324324 //缩略图的资源
325325 if ($ imgType === static ::IMAGE_GIF ) {
@@ -333,7 +333,7 @@ public function thumbnail($img, $outPath = '', $outFilename = '', $thumbWidth =
333333 }
334334
335335 // 绘制缩略图X
336- if (function_exists ('imagecopyresampled ' )) {
336+ if (\ function_exists ('imagecopyresampled ' )) {
337337 imagecopyresampled ($ resThumb , $ resImg , 0 , 0 , 0 , 0 , $ thumbSize [0 ], $ thumbSize [1 ], $ thumbSize [2 ], $ thumbSize [3 ]);
338338 } else {
339339 imagecopyresized ($ resThumb , $ resImg , 0 , 0 , 0 , 0 , $ thumbSize [0 ], $ thumbSize [1 ], $ thumbSize [2 ], $ thumbSize [3 ]);
@@ -350,7 +350,7 @@ public function thumbnail($img, $outPath = '', $outFilename = '', $thumbWidth =
350350 }
351351
352352 // generate image to dst file. imagepng(), imagegif(), imagejpeg(), imagewbmp()
353- call_user_func ("image {$ imgType }" , $ resThumb , $ outFile );
353+ \ call_user_func ("image {$ imgType }" , $ resThumb , $ outFile );
354354
355355 imagedestroy ($ resImg );
356356 imagedestroy ($ resThumb );
@@ -387,7 +387,7 @@ public static function show($img)
387387 }
388388
389389 /** @var resource $resImg */
390- $ resImg = call_user_func ("imagecreatefrom {$ type }" , $ img );
390+ $ resImg = \ call_user_func ("imagecreatefrom {$ type }" , $ img );
391391
392392 // 保持png图片的透明度
393393 if ($ type === self ::IMAGE_PNG ) {
@@ -592,7 +592,7 @@ public static function getImageTypes()
592592 */
593593 public static function isSupportedType ($ type )
594594 {
595- return in_array ($ type , static ::getImageTypes (), true );
595+ return \ in_array ($ type , static ::getImageTypes (), true );
596596 }
597597
598598 /**
0 commit comments