Skip to content
Snippets Groups Projects
Commit aeefe48c authored by Björn Schießle's avatar Björn Schießle
Browse files

Revert "use relative paths to create images from a file. This way it also works if"

This reverts commit 3488f0b7.
parent 3b904647
No related branches found
No related tags found
No related merge requests found
...@@ -414,61 +414,60 @@ class OC_Image { ...@@ -414,61 +414,60 @@ class OC_Image {
*/ */
public function loadFromFile($imagePath=false) { public function loadFromFile($imagePath=false) {
// exif_imagetype throws "read error!" if file is less than 12 byte // exif_imagetype throws "read error!" if file is less than 12 byte
$absPath = \OC\Files\Filesystem::getLocalFile($imagePath); if(!@is_file($imagePath) || !file_exists($imagePath) || filesize($imagePath) < 12 || !is_readable($imagePath)) {
if(!@is_file($absPath) || !file_exists($absPath) || filesize($absPath) < 12 || !is_readable($absPath)) {
// Debug output disabled because this method is tried before loadFromBase64? // Debug output disabled because this method is tried before loadFromBase64?
OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$absPath, OC_Log::DEBUG); OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$imagePath, OC_Log::DEBUG);
return false; return false;
} }
$iType = exif_imagetype($absPath); $iType = exif_imagetype($imagePath);
switch ($iType) { switch ($iType) {
case IMAGETYPE_GIF: case IMAGETYPE_GIF:
if (imagetypes() & IMG_GIF) { if (imagetypes() & IMG_GIF) {
$this->resource = imagecreatefromgif($absPath); $this->resource = imagecreatefromgif($imagePath);
} else { } else {
OC_Log::write('core', OC_Log::write('core',
'OC_Image->loadFromFile, GIF images not supported: '.$absPath, 'OC_Image->loadFromFile, GIF images not supported: '.$imagePath,
OC_Log::DEBUG); OC_Log::DEBUG);
} }
break; break;
case IMAGETYPE_JPEG: case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPG) { if (imagetypes() & IMG_JPG) {
$this->resource = imagecreatefromjpeg($absPath); $this->resource = imagecreatefromjpeg($imagePath);
} else { } else {
OC_Log::write('core', OC_Log::write('core',
'OC_Image->loadFromFile, JPG images not supported: '.$absPath, 'OC_Image->loadFromFile, JPG images not supported: '.$imagePath,
OC_Log::DEBUG); OC_Log::DEBUG);
} }
break; break;
case IMAGETYPE_PNG: case IMAGETYPE_PNG:
if (imagetypes() & IMG_PNG) { if (imagetypes() & IMG_PNG) {
$this->resource = imagecreatefrompng($absPath); $this->resource = imagecreatefrompng($imagePath);
} else { } else {
OC_Log::write('core', OC_Log::write('core',
'OC_Image->loadFromFile, PNG images not supported: '.$absPath, 'OC_Image->loadFromFile, PNG images not supported: '.$imagePath,
OC_Log::DEBUG); OC_Log::DEBUG);
} }
break; break;
case IMAGETYPE_XBM: case IMAGETYPE_XBM:
if (imagetypes() & IMG_XPM) { if (imagetypes() & IMG_XPM) {
$this->resource = imagecreatefromxbm($absPath); $this->resource = imagecreatefromxbm($imagePath);
} else { } else {
OC_Log::write('core', OC_Log::write('core',
'OC_Image->loadFromFile, XBM/XPM images not supported: '.$absPath, 'OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagePath,
OC_Log::DEBUG); OC_Log::DEBUG);
} }
break; break;
case IMAGETYPE_WBMP: case IMAGETYPE_WBMP:
if (imagetypes() & IMG_WBMP) { if (imagetypes() & IMG_WBMP) {
$this->resource = imagecreatefromwbmp($absPath); $this->resource = imagecreatefromwbmp($imagePath);
} else { } else {
OC_Log::write('core', OC_Log::write('core',
'OC_Image->loadFromFile, WBMP images not supported: '.$absPath, 'OC_Image->loadFromFile, WBMP images not supported: '.$imagePath,
OC_Log::DEBUG); OC_Log::DEBUG);
} }
break; break;
case IMAGETYPE_BMP: case IMAGETYPE_BMP:
$this->resource = $this->imagecreatefrombmp($absPath); $this->resource = $this->imagecreatefrombmp($imagePath);
break; break;
/* /*
case IMAGETYPE_TIFF_II: // (intel byte order) case IMAGETYPE_TIFF_II: // (intel byte order)
...@@ -497,7 +496,7 @@ class OC_Image { ...@@ -497,7 +496,7 @@ class OC_Image {
default: default:
// this is mostly file created from encrypted file // this is mostly file created from encrypted file
$this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents($imagePath)); $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
$iType = IMAGETYPE_PNG; $iType = IMAGETYPE_PNG;
OC_Log::write('core', 'OC_Image->loadFromFile, Default', OC_Log::DEBUG); OC_Log::write('core', 'OC_Image->loadFromFile, Default', OC_Log::DEBUG);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment