From 6f58e0613a47d9eeb5004c992e6c59b7cf9ec0ea Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 14 Feb 2010 17:31:45 +0100 Subject: [PATCH] Add PlImage, short wrapper to send images. Signed-off-by: Florent Bruneau --- classes/plimage.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 classes/plimage.php diff --git a/classes/plimage.php b/classes/plimage.php new file mode 100644 index 0000000..955df71 --- /dev/null +++ b/classes/plimage.php @@ -0,0 +1,93 @@ +mime); + if (empty($this->data)) { + readfile($this->file); + } else { + echo $this->data; + } + exit; + } + + public function path() + { + if (empty($this->data)) { + return $file; + } else { + $name = md5($this->data); + $GLOBALS['img' . $name] = $this->data; + return 'var://img' . $name; + } + } + + public function width() + { + return $this->x; + } + + public function height() + { + return $this->y; + } + + public function mimeType() + { + return $this->mime; + } + + public static function fromData($data, $mime, $x = null, $y = null) + { + $image = new PlImage(); + $image->data = $data; + $image->mime = $mime; + $image->x = $x; + $image->y = $y; + return $image; + } + + public static function fromFile($path, $mime, $x = null, $y = null) + { + $image = new PlImage(); + $image->file = $path; + $image->mime = $mime; + $image->x = $x; + $image->y = $y; + return $image; + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> -- 2.1.4