1
1
<?php
2
2
3
- namespace iBrand \Poster ;
3
+ namespace iBrand \Miniprogram \ Poster ;
4
4
5
5
use Anam \PhantomMagick \Converter ;
6
- use Illuminate \ Support \ Facades \ Storage ;
6
+ use Storage ;
7
7
8
8
class MiniProgramShareImg
9
9
{
@@ -25,25 +25,26 @@ public static function generateShareImage($route)
25
25
}
26
26
27
27
$ options = [
28
- 'dimension ' => config ('phantommagick .width ' , '575px ' ),
29
- 'zoomfactor ' => config ('phantommagick .zoomfactor ' , 1.5 ),
30
- 'quality ' => config ('phantommagick .quality ' , 100 ),
28
+ 'dimension ' => config ('ibrand.miniprogram-poster .width ' , '575px ' ),
29
+ 'zoomfactor ' => config ('ibrand.miniprogram-poster .zoomfactor ' , 1.5 ),
30
+ 'quality ' => config ('ibrand.miniprogram-poster .quality ' , 100 ),
31
31
];
32
32
33
- $ saveName = config ('phantommagick .directory ' ) . '/ ' . md5 (uniqid ()) . '.png ' ;
34
- $ root = config ('phantommagick .disks.MiniProgramShare.root ' );
33
+ $ saveName = config ('ibrand.miniprogram-poster .directory ' ) . '/ ' . md5 (uniqid ()) . '.png ' ;
34
+ $ root = config ('ibrand.miniprogram-poster .disks.MiniProgramShare.root ' );
35
35
$ file = $ root . '/ ' . $ saveName ;
36
36
37
37
try {
38
38
$ converter = self ::init ();
39
39
40
40
$ converter ->source ($ route )->toPng ($ options )->save ($ file );
41
41
42
- if (config ('phantommagick .compress ' , true )) {
42
+ if (config ('ibrand.miniprogram-poster .compress ' , true )) {
43
43
self ::imagePngSizeAdd ($ file );
44
44
}
45
45
46
46
return Storage::disk ('MiniProgramShare ' )->url ($ saveName );
47
+
47
48
} catch (\Exception $ exception ) {
48
49
49
50
return false ;
@@ -60,7 +61,7 @@ public static function imagePngSizeAdd($file)
60
61
$ resource = imagecreatetruecolor ($ new_width , $ new_height );
61
62
$ image = imagecreatefrompng ($ file );
62
63
imagecopyresampled ($ resource , $ image , 0 , 0 , 0 , 0 , $ new_width , $ new_height , $ width , $ height );
63
- imagejpeg ($ resource , $ file , config ('phantommagick .quality ' ));
64
+ imagejpeg ($ resource , $ file , config ('ibrand.miniprogram-poster .quality ' ));
64
65
imagedestroy ($ resource );
65
66
}
66
67
}
0 commit comments