Browse Source

Check for $this->fileInfo and @depend on testData()

tags/v6.0.0alpha2
kondou 11 years ago
parent
commit
2d6a400381
2 changed files with 5 additions and 2 deletions
  1. 2
    2
      lib/image.php
  2. 3
    0
      tests/lib/image.php

+ 2
- 2
lib/image.php View File

return false; return false;
} }
$this->resource = @imagecreatefromstring($str); $this->resource = @imagecreatefromstring($str);
if (\OC_Util::fileInfoLoaded()) {
if ($this->fileInfo) {
$this->mimeType = $this->fileInfo->buffer($str); $this->mimeType = $this->fileInfo->buffer($str);
} }
if(is_resource($this->resource)) { if(is_resource($this->resource)) {
$data = base64_decode($str); $data = base64_decode($str);
if($data) { // try to load from string data if($data) { // try to load from string data
$this->resource = @imagecreatefromstring($data); $this->resource = @imagecreatefromstring($data);
if (\OC_Util::fileInfoLoaded()) {
if ($this->fileInfo) {
$this->mimeType = $this->fileInfo->buffer($data); $this->mimeType = $this->fileInfo->buffer($data);
} }
if(!$this->resource) { if(!$this->resource) {

+ 3
- 0
tests/lib/image.php View File

$this->assertEquals($expected, $img->data()); $this->assertEquals($expected, $img->data());
} }


/**
* @depends testData
*/
public function testToString() { public function testToString() {
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png'); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
$expected = base64_encode($img->data()); $expected = base64_encode($img->data());

Loading…
Cancel
Save