Skip to content

Commit c02ddc0

Browse files
committed
fix: handle dataurl by manual
1 parent 6be4d3b commit c02ddc0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Thumbnail.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ class Thumbnail {
88
public $height;
99
public $type;
1010

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);
1317
list($this->width, $this->height, $this->type) = $imageInfo;
1418

1519
switch ($this->type) {
1620
case IMAGETYPE_GIF:
17-
$this->image = imagecreatefromgif($url);
18-
break;
1921
case IMAGETYPE_PNG:
20-
$this->image = imagecreatefrompng($url);
21-
break;
2222
case IMAGETYPE_JPEG:
23-
$this->image = imagecreatefromjpeg($url);
23+
$this->image = imagecreatefromstring($data);
2424
break;
2525
}
2626
}

0 commit comments

Comments
 (0)