cvs: pear /Image_Canvas/Canvas SVG.php /Image_Canvas/docs ChangeLog /Image_Canvas/tests canvas_body.php
| From: | Jesper Veggerby Hansen | Date: | Tue, 16 Aug 2005 19:55:14 +0000 |
| Subject: | cvs: pear /Image_Canvas/Canvas SVG.php /Image_Canvas/docs ChangeLog /Image_Canvas/tests canvas_body.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-34027@lists.php.net to get a copy of this message | ||
nosey Tue Aug 16 15:55:14 2005 EDT
Modified files:
/pear/Image_Canvas/docs ChangeLog
/pear/Image_Canvas/Canvas SVG.php
/pear/Image_Canvas/tests canvas_body.php
Log:
Added image support when using SVG (using embedded base64 encoding)
http://cvs.php.net/diff.php/pear/Image_Canvas/docs/ChangeLog?r1=1.4&r2=1.5&ty=u
Index: pear/Image_Canvas/docs/ChangeLog
diff -u pear/Image_Canvas/docs/ChangeLog:1.4 pear/Image_Canvas/docs/ChangeLog:1.5
--- pear/Image_Canvas/docs/ChangeLog:1.4 Wed Aug 10 16:01:03 2005
+++ pear/Image_Canvas/docs/ChangeLog Tue Aug 16 15:55:12 2005
@@ -1,8 +1,9 @@
**************************
Image_Canvas - Changelog
**************************
-Version 0.2.1 [2005-xxx-xxx] - Jesper Veggerby <pear.nosey@veggerby.dk>
+Version 0.2.2 [2005-xxx-xxx] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Added 'border' and 'cssclass' option to Image_Canvas_GD::toHtml()
+ * Added image support when using SVG (using embedded base64 encoding)
* Fixed bug where 'htmltags' were not transferred to image mapping of polygon
vertices
Version 0.2.1 [2005-Aug-08] - Jesper Veggerby <pear.nosey@veggerby.dk>
http://cvs.php.net/diff.php/pear/Image_Canvas/Canvas/SVG.php?r1=1.2&r2=1.3&ty=u
Index: pear/Image_Canvas/Canvas/SVG.php
diff -u pear/Image_Canvas/Canvas/SVG.php:1.2 pear/Image_Canvas/Canvas/SVG.php:1.3
--- pear/Image_Canvas/Canvas/SVG.php:1.2 Thu Aug 4 15:24:39 2005
+++ pear/Image_Canvas/Canvas/SVG.php Tue Aug 16 15:55:14 2005
@@ -21,7 +21,7 @@
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL
License 2.1
- * @version CVS: $Id: SVG.php,v 1.2 2005/08/04 19:24:39 nosey Exp $
+ * @version CVS: $Id: SVG.php,v 1.3 2005/08/16 19:55:14 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@@ -715,17 +715,22 @@
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$filename = $params['filename'];
- $width = (isset($params['width']) ? $params['width'] : false);
- $height = (isset($params['height']) ? $params['height'] : false);
+
+ list($width, $height, $type, $attr) = getimagesize($filename);
+ $width = (isset($params['width']) ? $params['width'] : $width);
+ $height = (isset($params['height']) ? $params['height'] : $height);
$alignment = (isset($params['alignment']) ? $params['alignment'] :
false);
- // TODO Make images work in SVG
- $filename = 'file:///' . str_replace('\\', '/', $filename);
+ $file = fopen($filename, 'rb');
+ $filedata = fread($file, filesize($filename));
+ fclose($file);
+
+ $data = 'data:' . image_type_to_mime_type($type) . ';base64,' .
base64_encode($filedata);
$this->_addElement(
- '<image xlink:href="' . $filename . '" x="' . $x
. '" y="' . $y .
- ($width ? '" width="' . $width : '') .
- ($height ? '" height="' . $height : '') .
- '"/>'
+ '<image xlink:href="' . $data . '" x="' . $x .
'" y="' . $y . '"' .
+ ($width ? ' width="' . $width . '"' : '') .
+ ($height ? ' height="' . $height . '"' :
'') .
+ ' preserveAspectRatio="none"/>'
);
parent::image($params);
}
http://cvs.php.net/diff.php/pear/Image_Canvas/tests/canvas_body.php?r1=1.2&r2=1.3&ty=u
Index: pear/Image_Canvas/tests/canvas_body.php
diff -u pear/Image_Canvas/tests/canvas_body.php:1.2 pear/Image_Canvas/tests/canvas_body.php:1.3
--- pear/Image_Canvas/tests/canvas_body.php:1.2 Wed Aug 3 17:17:48 2005
+++ pear/Image_Canvas/tests/canvas_body.php Tue Aug 16 15:55:14 2005
@@ -25,7 +25,7 @@
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL
License 2.1
- * @version CVS: $Id: canvas_body.php,v 1.2 2005/08/03 21:17:48 nosey Exp $
+ * @version CVS: $Id: canvas_body.php,v 1.3 2005/08/16 19:55:14 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@@ -311,6 +311,16 @@
$canvas->image(array('x' => 445, 'y' => 523, 'filename'
=> './pear-icon.png', 'width' => 40, 'height' => 40));
-$canvas->show();
+//$canvas->show();
+$type = basename($_SERVER['SCRIPT_NAME'], '.php');
+$canvas->toHtml(
+ array(
+ 'filename' => 'test' . $type . '.' . $type,
+ 'urlpath' => '',
+ 'filepath' => './',
+ 'width' => '100%',
+ 'height' => '100%'
+ )
+);
?>
\ No newline at end of file