From 9dbb07b806c3795d1910f6998c644977d06746e2 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 5 Jun 2012 20:19:27 +0200 Subject: [PATCH] Added data() method to OC_Image to return raw image data. --- lib/image.php | 15 +++++++++++---- 1 file 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()); } /** -- 2.39.5