File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,19 @@ class Thumbnail {
8
8
public $ height ;
9
9
public $ type ;
10
10
11
- private function __construct ($ url ) {
12
- $ imageInfo = getimagesize ($ url );
11
+ private function __construct ($ dataUrl ) {
12
+ list ($ type , $ data ) = explode ('; ' , $ dataUrl );
13
+ list (, $ data ) = explode (', ' , $ data );
14
+ $ data = base64_decode ($ data );
15
+
16
+ $ imageInfo = getimagesizefromstring ($ data );
13
17
list ($ this ->width , $ this ->height , $ this ->type ) = $ imageInfo ;
14
18
15
19
switch ($ this ->type ) {
16
20
case IMAGETYPE_GIF :
17
- $ this ->image = imagecreatefromgif ($ url );
18
- break ;
19
21
case IMAGETYPE_PNG :
20
- $ this ->image = imagecreatefrompng ($ url );
21
- break ;
22
22
case IMAGETYPE_JPEG :
23
- $ this ->image = imagecreatefromjpeg ( $ url );
23
+ $ this ->image = imagecreatefromstring ( $ data );
24
24
break ;
25
25
}
26
26
}
You can’t perform that action at this time.
0 commit comments