Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2014-03-14 14:13:45 +0400
committerGeorg Ehrke <developer@georgehrke.com>2014-08-26 21:35:53 +0400
commit8f45e8107aa5557f5d0bbe8b164cfba5674a3222 (patch)
treea54704ff327ad33eedb47a84fe0ff43fd09785e9 /lib
parent30098c34ad50878f266f6ee125008b9254b61af1 (diff)
make it possible to influence output type of \OC_Image
Conflicts: lib/private/image.php
Diffstat (limited to 'lib')
-rw-r--r--lib/private/image.php48
1 files changed, 40 insertions, 8 deletions
diff --git a/lib/private/image.php b/lib/private/image.php
index 7761a3c7737..b704e2828f6 100644
--- a/lib/private/image.php
+++ b/lib/private/image.php
@@ -155,9 +155,12 @@ class OC_Image {
* @brief Outputs the image.
* @returns bool
*/
- public function show() {
- header('Content-Type: '.$this->mimeType());
- return $this->_output();
+ public function show($mimeType=null) {
+ if($mimeType === null) {
+ $mimeType = $this->mimeType();
+ }
+ header('Content-Type: '.$mimeType);
+ return $this->_output(null, $mimeType);
}
/**
@@ -165,20 +168,23 @@ class OC_Image {
* @returns bool
*/
- public function save($filePath=null) {
+ public function save($filePath=null, $mimeType=null) {
+ if($mimeType === null) {
+ $mimeType = $this->mimeType();
+ }
if($filePath === null && $this->filePath === null) {
OC_Log::write('core', __METHOD__.'(): called with no path.', OC_Log::ERROR);
return false;
} elseif($filePath === null && $this->filePath !== null) {
$filePath = $this->filePath;
}
- return $this->_output($filePath);
+ return $this->_output($filePath, $mimeType);
}
/**
* @brief Outputs/saves the image.
*/
- private function _output($filePath=null) {
+ private function _output($filePath=null, $mimeType=null) {
if($filePath) {
if (!file_exists(dirname($filePath)))
mkdir(dirname($filePath), 0777, true);
@@ -196,8 +202,34 @@ class OC_Image {
return false;
}
- $retVal = false;
- switch($this->imageType) {
+ $imageType = null;
+ if($mimeType !== null) {
+ switch($mimeType) {
+ case 'image/gif':
+ $this->imageType = IMAGETYPE_GIF;
+ break;
+ case 'image/jpeg':
+ case 'image/pjpeg':
+ $this->imageType = IMAGETYPE_JPEG;
+ break;
+ case 'image/png':
+ $this->imageType = IMAGETYPE_PNG;
+ break;
+ case 'image/x-xbitmap':
+ $this->imageType = IMAGETYPE_XBM;
+ break;
+ case 'image/bmp':
+ $this->imageType = IMAGETYPE_BMP;
+ break;
+ default:
+ $this->imageType = IMAGETYPE_PNG;
+ break;
+ }
+ } else {
+ $imageType = $this->imageType;
+ }
+
+ switch($imageType) {
case IMAGETYPE_GIF:
$retVal = imagegif($this->resource, $filePath);
break;