Skip to content

Commit 67b0746

Browse files
Merge pull request #119 from jgullstr/master
Support RFC 2397 data urls
2 parents d36a7bc + da930ef commit 67b0746

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/ImageResize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function __construct($filename)
105105
if (!defined('IMAGETYPE_WEBP')) {
106106
define('IMAGETYPE_WEBP', 18);
107107
}
108-
if ($filename === null || empty($filename) || (substr($filename, 0, 7) !== 'data://' && !is_file($filename))) {
108+
if ($filename === null || empty($filename) || (substr($filename, 0, 5) !== 'data:' && !is_file($filename))) {
109109
throw new ImageResizeException('File does not exist');
110110
}
111111

test/ImageResizeTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ImageResizeTest extends TestCase
1515

1616
private $unsupported_image = 'Qk08AAAAAAAAADYAAAAoAAAAAQAAAAEAAAABABAAAAAAAAYAAAASCwAAEgsAAAAAAAAAAAAA/38AAAAA';
1717
private $image_string = 'R0lGODlhAQABAIAAAAQCBP///yH5BAEAAAEALAAAAAABAAEAAAICRAEAOw==';
18+
private $data_url = 'data:image/gif;base64,R0lGODlhAQABAIAAAAQCBP///yH5BAEAAAEALAAAAAABAAEAAAICRAEAOw==';
1819

1920

2021
/**
@@ -65,6 +66,14 @@ public function testLoadString()
6566
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
6667
}
6768

69+
public function testLoadRfc2397()
70+
{
71+
$resize = new ImageResize($this->data_url);
72+
73+
$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
74+
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
75+
}
76+
6877
public function testAddFilter()
6978
{
7079
$image = $this->createImage(1, 1, 'png');

0 commit comments

Comments
 (0)