aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-13 10:10:11 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-16 12:45:15 +0100
commit8ed27d2ce0477f40a27cdc335361b0d5654a7e09 (patch)
treede2db82b384ab3071c2c17b8e84dd560b9df993c /lib/private
parent3b7aec1b7d4e2e3a1ff6c1f7888189c67aa09b75 (diff)
downloadnextcloud-server-8ed27d2ce0477f40a27cdc335361b0d5654a7e09.tar.gz
nextcloud-server-8ed27d2ce0477f40a27cdc335361b0d5654a7e09.zip
Create an interface for OC_Image and OCP\Image for the public API
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/avatar.php6
-rw-r--r--lib/private/image.php7
-rw-r--r--lib/private/preview.php12
-rw-r--r--lib/private/preview/movie.php2
-rw-r--r--lib/private/preview/mp3.php3
-rw-r--r--lib/private/preview/provider.php4
-rw-r--r--lib/private/previewmanager.php2
7 files changed, 18 insertions, 18 deletions
diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index 23b3c82771a..da9c84d84a4 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -29,7 +29,7 @@ class Avatar implements \OCP\IAvatar {
/**
* get the users avatar
* @param int $size size in px of the avatar, avatars are square, defaults to 64
- * @return boolean|\OC_Image containing the avatar or false if there's no image
+ * @return boolean|\OCP\IImage containing the avatar or false if there's no image
*/
public function get ($size = 64) {
if ($this->view->file_exists('avatar.jpg')) {
@@ -57,14 +57,14 @@ class Avatar implements \OCP\IAvatar {
/**
* sets the users avatar
- * @param \OC_Image|resource|string $data OC_Image, imagedata or path to set a new avatar
+ * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar
* @throws \Exception if the provided file is not a jpg or png image
* @throws \Exception if the provided image is not valid
* @throws \OC\NotSquareException if the image is not square
* @return void
*/
public function set ($data) {
- if($data instanceOf OC_Image) {
+ if($data instanceOf \OCP\IImage) {
$img = $data;
$data = $img->data();
} else {
diff --git a/lib/private/image.php b/lib/private/image.php
index 2484aeecc63..c8509c61286 100644
--- a/lib/private/image.php
+++ b/lib/private/image.php
@@ -15,7 +15,7 @@
/**
* Class for basic image manipulation
*/
-class OC_Image {
+class OC_Image implements \OCP\IImage {
protected $resource = false; // tmp resource.
protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident.
protected $mimeType = "image/png"; // Default to png
@@ -285,7 +285,7 @@ class OC_Image {
/**
* @return null|string Returns the raw image data.
*/
- function data() {
+ public function data() {
if (!$this->valid()) {
return null;
}
@@ -949,6 +949,9 @@ class OC_Image {
return true;
}
+ /**
+ * Destroys the current image and resets the object
+ */
public function destroy() {
if ($this->valid()) {
imagedestroy($this->resource);
diff --git a/lib/private/preview.php b/lib/private/preview.php
index cb3554fa1e9..f69b0d6c971 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -46,7 +46,7 @@ class Preview {
/**
* preview images object
*
- * @var \OC_Image
+ * @var \OCP\IImage
*/
private $preview;
@@ -465,7 +465,7 @@ class Preview {
/**
* return a preview of a file
- * @return \OC_Image
+ * @return \OCP\IImage
*/
public function getPreview() {
if (!is_null($this->preview) && $this->preview->valid()) {
@@ -518,7 +518,7 @@ class Preview {
/** @var $provider Provider */
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
- if (!($preview instanceof \OC_Image)) {
+ if (!($preview instanceof \OCP\IImage)) {
continue;
}
@@ -564,7 +564,7 @@ class Preview {
if (is_null($this->preview)) {
$this->getPreview();
}
- if ($this->preview instanceof \OC_Image) {
+ if ($this->preview instanceof \OCP\IImage) {
$this->preview->show($mimeType);
}
}
@@ -580,8 +580,8 @@ class Preview {
$scalingUp = $this->getScalingUp();
$maxScaleFactor = $this->getMaxScaleFactor();
- if (!($image instanceof \OC_Image)) {
- \OC_Log::write('core', '$this->preview is not an instance of OC_Image', \OC_Log::DEBUG);
+ if (!($image instanceof \OCP\IImage)) {
+ \OC_Log::write('core', '$this->preview is not an instance of \OCP\IImage', \OC_Log::DEBUG);
return;
}
diff --git a/lib/private/preview/movie.php b/lib/private/preview/movie.php
index 06353ddebb7..85151f5dbaa 100644
--- a/lib/private/preview/movie.php
+++ b/lib/private/preview/movie.php
@@ -61,7 +61,7 @@ class Movie extends Provider {
* @param int $maxY
* @param string $absPath
* @param int $second
- * @return bool|\OC_Image
+ * @return bool|\OCP\IImage
*/
private function generateThumbNail($maxX, $maxY, $absPath, $second) {
$tmpPath = \OC_Helper::tmpFile();
diff --git a/lib/private/preview/mp3.php b/lib/private/preview/mp3.php
index f1a50d99e13..19360f4f036 100644
--- a/lib/private/preview/mp3.php
+++ b/lib/private/preview/mp3.php
@@ -39,8 +39,7 @@ class MP3 extends Provider {
/**
* Generates a default image when the file has no cover
*
- * @return false|\OC_Image False if the default image is missing or invalid,
- * otherwise the image is returned as \OC_Image
+ * @return bool|\OCP\IImage false if the default image is missing or invalid
*/
private function getNoCoverThumbnail() {
$icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png';
diff --git a/lib/private/preview/provider.php b/lib/private/preview/provider.php
index 3cce8c2ab85..1d6fac13965 100644
--- a/lib/private/preview/provider.php
+++ b/lib/private/preview/provider.php
@@ -37,9 +37,7 @@ abstract class Provider implements IProvider {
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
* @param bool $scalingup Disable/Enable upscaling of previews
* @param \OC\Files\View $fileview fileview object of user folder
- * @return mixed
- * false if no preview was generated
- * OC_Image object of the preview
+ * @return bool|\OCP\IImage false if no preview was generated
*/
abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview);
}
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php
index 0d3ec40c06b..0a0c47df28f 100644
--- a/lib/private/previewmanager.php
+++ b/lib/private/previewmanager.php
@@ -96,7 +96,7 @@ class PreviewManager implements IPreview {
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
* @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
- * @return \OCP\Image
+ * @return \OCP\IImage
*/
public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false) {
$preview = new \OC\Preview('', '/', $file, $maxX, $maxY, $scaleUp);