@@ -59,23 +59,36 @@ public function get($filename, $size = null)
59
59
60
60
public function getWatermark ($ filename , $ watermark )
61
61
{
62
- $ path = $ this ->basepath . $ filename ;
63
- $ image_types = array ('image/png ' , 'image/gif ' , 'image/jpeg ' , 'image/jpg ' );
64
- $ watermark_image = $ this ->setTmpImage (base_path ($ watermark ));
65
- $ image = $ this ->setTmpImage (storage_path ('app/ ' . $ path ));
66
- imagesavealpha ($ watermark_image , true );
67
- imagesetbrush ($ image , $ watermark_image );
68
- $ watermark_pos_x = imagesx ($ image ) - imagesy ($ watermark_image );
69
- $ watermark_pos_y = imagesy ($ image ) - imagesy ($ watermark_image );
70
- imageline ($ image , $ watermark_pos_x , $ watermark_pos_y , $ watermark_pos_x , $ watermark_pos_y , IMG_COLOR_BRUSHED );
71
- imagesavealpha ($ image , true );
72
- if (!Storage::exists ('images/wtermark ' )) {
73
- Storage::makeDirectory ('images/watermark ' );
74
- }
75
- imagepng ($ image , storage_path ('app/images/watermark/ ' . $ filename ));
62
+ $ origin_basepath = $ this ->basepath ;
63
+ try {
64
+ $ path = $ this ->basepath . $ filename ;
65
+ $ image_types = array ('image/png ' , 'image/gif ' , 'image/jpeg ' , 'image/jpg ' );
66
+ $ watermark_image = $ this ->setTmpImage (base_path ($ watermark ));
67
+ $ image = $ this ->setTmpImage (storage_path ('app/ ' . $ path ));
68
+ imagesavealpha ($ watermark_image , true );
69
+ imagesetbrush ($ image , $ watermark_image );
70
+ $ watermark_pos_x = imagesx ($ image ) - imagesy ($ watermark_image );
71
+ $ watermark_pos_y = imagesy ($ image ) - imagesy ($ watermark_image );
72
+ imageline (
73
+ $ image ,
74
+ $ watermark_pos_x ,
75
+ $ watermark_pos_y ,
76
+ $ watermark_pos_x ,
77
+ $ watermark_pos_y ,
78
+ IMG_COLOR_BRUSHED
79
+ );
80
+ imagesavealpha ($ image , true );
81
+ if (!Storage::exists ('images/wtermark ' )) {
82
+ Storage::makeDirectory ('images/watermark ' );
83
+ }
84
+ imagepng ($ image , storage_path ('app/images/watermark/ ' . $ filename ));
76
85
77
- $ this ->basepath = 'images/watermark/ ' ;
78
- return $ this ->getResponse ($ filename );
86
+ $ this ->basepath = 'images/watermark/ ' ;
87
+ return $ this ->getResponse ($ filename );
88
+ } catch (\Exception $ e ) {
89
+ $ this ->basepath = $ origin_basepath ;
90
+ return $ this ->getResponse ($ filename );
91
+ }
79
92
}
80
93
81
94
public function thumbs ($ thumb_sizes = array ())
0 commit comments