diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-06-05 20:19:27 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-06-05 20:31:15 +0200 |
commit | 9dbb07b806c3795d1910f6998c644977d06746e2 (patch) | |
tree | c3734add37282153cfbdc6b0ad97f2f36e3cfa6a /lib/image.php | |
parent | 301a14dcd6502f3eaaa621476c1fd788727f60ec (diff) | |
download | nextcloud-server-9dbb07b806c3795d1910f6998c644977d06746e2.tar.gz nextcloud-server-9dbb07b806c3795d1910f6998c644977d06746e2.zip |
Added data() method to OC_Image to return raw image data.
Diffstat (limited to 'lib/image.php')
-rw-r--r-- | lib/image.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/image.php b/lib/image.php index 4c53dc32f58..a6bb92cea27 100644 --- a/lib/image.php +++ b/lib/image.php @@ -187,15 +187,22 @@ class OC_Image { } /** - * @returns Returns a base64 encoded string suitable for embedding in a VCard. + * @returns Returns the raw image data. */ - function __toString() { + function data() { ob_start(); $res = imagepng($this->resource); if (!$res) { - OC_Log::write('core','OC_Image->__toString. Error writing image',OC_Log::ERROR); + OC_Log::write('core','OC_Image->data. Error getting image data.',OC_Log::ERROR); } - return base64_encode(ob_get_clean()); + return ob_get_clean(); + } + + /** + * @returns Returns a base64 encoded string suitable for embedding in a VCard. + */ + function __toString() { + return base64_encode($this->data()); } /** |