cvs: php4 /pear/Image Remote.php
| From: | Mika Tuupola | Date: | Mon, 13 Aug 2001 13:31:24 +0000 |
| Subject: | cvs: php4 /pear/Image Remote.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-490@lists.php.net to get a copy of this message | ||
tuupola Mon Aug 13 09:31:24 2001 EDT
Modified files:
/php4/pear/Image Remote.php
Log:
* Fix PHPDoc
Index: php4/pear/Image/Remote.php
diff -u php4/pear/Image/Remote.php:1.5 php4/pear/Image/Remote.php:1.6
--- php4/pear/Image/Remote.php:1.5 Sun May 13 10:23:04 2001
+++ php4/pear/Image/Remote.php Mon Aug 13 09:31:24 2001
@@ -17,7 +17,7 @@
// | Authors: Mika Tuupola <tuupola@appelsiini.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Remote.php,v 1.5 2001/05/13 14:23:04 tuupola Exp $
+// $Id: Remote.php,v 1.6 2001/08/13 13:31:24 tuupola Exp $
define("GIF_SIGNATURE_LENGTH", 3);
define("GIF_VERSION_LENGTH", 3);
@@ -64,39 +64,108 @@
require_once('PEAR.php');
+/**
+ * Image_Remote - retrieve size from remote image files.
+ *
+ * Class can be used to get size information from remote
+ * image files without downloading the whole image file.
+ * It mimics the GetImageSize() PHP function but works on
+ * remote images. Gif, jpeg and png currently supported.
+ *
+ * NOTE: Since PHP 4.0.5 URL support was added also to PHP's native
+ * GetImageSize().
+ *
+ * Usage:
+ *
+ * $i = new Image_Remote("http://www.example.com/test.png");
+ * if (PEAR::isError($i)) {
+ * print "ERROR: " . $i->getMessage();
+ * } else {
+ * $data = $i->getImageSize();
+ * }
+ *
+ *
+ * @access public
+ * @author Mika Tuupola <tuupola@appelsiini.net>
+ * @version $Revision: 1.6 $
+ */
+
+
class Image_Remote
{
- var $url; // the url we should be handling
- var $purl; // parsed url
+
+ /**
+ * The URL to fetch size from
+ *
+ * @var string
+ */
+ var $url;
+
+ /**
+ * Parsed URL
+ *
+ * @var array
+ */
+ var $purl;
+
+ /**
+ * Filesize of the remote image
+ *
+ * @var integer
+ */
+
var $filesize; // filesize of the remote file
- var $mimetype; // mimetype of the remote url
- var $imagetype; // imagetype
+
+ /**
+ * Mimetype of the remote image
+ *
+ * @var string
+ */
+ var $mimetype;
+
+ /**
+ * Imagetype of the remote image
+ *
+ * @var integer
+ */
+ var $imagetype;
+
+ /**
+ * Width of the remote image
+ *
+ * @var integer
+ */
var $width; // image width
+
+ /**
+ * Height of the remote image
+ *
+ * @var integer
+ */
var $height; // image height
+
+ /**
+ * Some useless extrainfo
+ *
+ * @var string
+ */
var $extra; // some useless extrainfo
+
+
+ /**
+ * Error of the last method call
+ *
+ * @var string
+ */
var $errstr; // error of the last method call
- /**
- * Image_Remote is a class to retrieve information on remote
- * imagefiles without actually downloading the whole image.
- * It mimics the GetImageSize() PHP function but works on
- * remote images. Gif, jpeg and png currently supported.
- *
- * Usage:
- *
- * $i = new Image_Remote("http://www.example.com/test.png");
- * if (PEAR::isError($i)) {
- * print "ERROR: " . $i->getMessage();
- * } else {
- * $data = $i->getImageSize();
- * }
- *
- * @param string $input URL of the remote image. Currently supports
- * only http.
- *
- * @author Mika Tuupola <tuupola@appelsiini.net>
- * @version $Revision: 1.5 $
- */
+ /**
+ * Constructor
+ *
+ * @param string foo URL of the remote image. Currently supports only http.
+ * @return object
+ *
+ */
function Image_Remote($input)
{
@@ -124,18 +193,16 @@
} // constructor
- /**
- * Gets information on the remote image. Imitates PHP's native
- * GetImageSize.
- *
- * http://www.php.net/manual/function.getimagesize.php
- *
- * @return array where array[0] contains the width of the image,
- * array[1] contains the height of the image, array[2] contains
- * an integer indicating type of the image. 1 = GIF, 2 = JPG,
- * 3 = PNG. array[3] contains a string in WIDTH="X" HEIGHT="X"
- * format.
- */
+ /**
+ * Return information on the remote image.
+ *
+ * Imitates PHP's native GetImageSize.
+ *
+ * http://www.php.net/manual/function.getimagesize.php
+ *
+ * @access public
+ * @return array
+ */
function getImageSize()
{
$retval = array(0,0,0,"");
@@ -148,19 +215,29 @@
return($retval);
}
- /**
- * Gets the URL of the remote image. This is actually the same URL
- * which was given to the constructor. However it sometimes comes
- * handy to be able to retrieve the URL again from the object.
- *
- * @return string URL
- */
+ /**
+ * Return the URL of the remote image.
+ *
+ * This is actually the same URL which was given to the constructor.
+ * However it sometimes comes handy to be able to retrieve the URL
+ * again from the object.
+ *
+ * @access public
+ * @return string
+ */
+
function getImageURL()
{
$retval = $this->url;
return($retval);
}
+ /**
+ * Fetch information of the remote image.
+ *
+ * @access private
+ * @return boolean
+ */
function _fetchImageInfo()
{
@@ -244,6 +321,12 @@
} // _fetchImageInfo
+ /**
+ * Parse GIF header
+ *
+ * @access private
+ * @return void
+ */
function _fetchAndParseGIFHeader($fd)
{
if (!$fd) {
@@ -262,6 +345,12 @@
}
}
+ /**
+ * Parse PNG header
+ *
+ * @access private
+ * @return void
+ */
function _fetchAndParsePNGHeader($fd)
{
@@ -292,6 +381,12 @@
//
// ftp://ftp.elq.org/pub/php3/elqGetImageFormat/elqGetImageFormat.php3
+ /**
+ * Parse JPEG header
+ *
+ * @access private
+ * @return void
+ */
function _fetchAndParseJPGHeader($fd)
{
@@ -369,6 +464,12 @@
}
}
+ /**
+ * Host byte order to decimal long
+ *
+ * @access private
+ * @return integer
+ */
function _htodecl($bytes)
{
$b1 = ord($bytes[0]);
@@ -378,6 +479,12 @@
return($b1 + $b2 + $b3 + $b4);
}
+ /**
+ * Host byte order to decimal short
+ *
+ * @access private
+ * @return integer
+ */
function _htodecs($bytes)
{
$b1 = ord($bytes[0]);
@@ -385,6 +492,12 @@
return($b1 + $b2);
}
+ /**
+ * Network byte order to decimal long
+ *
+ * @access private
+ * @return integer
+ */
function _ntodecl($bytes)
{
$b1 = ord($bytes[3]);
@@ -394,6 +507,12 @@
return($b1 + $b2 + $b3 + $b4);
}
+ /**
+ * Network byte order to decimal short
+ *
+ * @access private
+ * @return integer
+ */
function _ntodecs($bytes)
{
$b1 = ord($bytes[1]);