cvs: pear /Image_Transform Image_Transform.php Image_Transform_GD.php Image_Transform_IM.php Image_Transform_NetPBM.php
| From: | Peter Bowyer | Date: | Mon, 20 May 2002 16:28:47 +0000 |
| Subject: | cvs: pear /Image_Transform Image_Transform.php Image_Transform_GD.php Image_Transform_IM.php Image_Transform_NetPBM.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3973@lists.php.net to get a copy of this message | ||
reywob Mon May 20 12:28:47 2002 EDT
Modified files:
/pear/Image_Transform Image_Transform.php Image_Transform_GD.php
Image_Transform_IM.php
Image_Transform_NetPBM.php
Log:
Few fixes. Image_Transform_IM now works
Index: pear/Image_Transform/Image_Transform.php
diff -u pear/Image_Transform/Image_Transform.php:1.1 pear/Image_Transform/Image_Transform.php:1.2
--- pear/Image_Transform/Image_Transform.php:1.1 Thu May 16 14:08:26 2002
+++ pear/Image_Transform/Image_Transform.php Mon May 20 12:28:47 2002
@@ -17,7 +17,7 @@
// | Vincent Oostindie <vincent@sunlight.tmfweb.nl> |
// +----------------------------------------------------------------------+
//
-// $Id: Image_Transform.php,v 1.1 2002/05/16 18:08:26 reywob Exp $
+// $Id: Image_Transform.php,v 1.2 2002/05/20 16:28:47 reywob Exp $
//
// Image Transformation interface
//
@@ -134,17 +134,10 @@
function resize($new_x = 0, $new_y = 0)
{
// 0 means keep original size
- if (0 == $new_x) {
- $new_x = $this->img_x;
- }
- if (0 == $new_y) {
- $new_y = $this->img_y;
- }
- // Record the new size of the image
- $this->new_x = $this->_parse_size($new_x, $this->img_x);
- $this->new_y = $this->_parse_size($new_y, $this->img_y);
+ $new_x = (0 == $new_x) ? $this->img_x : $this->_parse_size($new_x, $this->img_x);
+ $new_y = (0 == $new_y) ? $this->img_y : $this->_parse_size($new_y, $this->img_y);
// Now do the library specific resizing.
- $this->_resize($this->new_x, $this->new_y);
+ $this->_resize($new_x, $new_y);
} // End resize
@@ -192,19 +185,6 @@
}
} // End scale
- /* The old scale function!
- function scale($size)
- {
- if ($this->img_x >= $this->img_y) {
- $new_x = _parse_size($size, $this->img_x);
- $new_y = round(($new_x / $this->img_x) * $this->img_y, 0);
- } else {
- $new_y = _parse_size($size, $this->img_y);
- $new_x = round(($new_y / $this->img_y) * $this->img_x, 0);
- }
- $this->_resize($new_x, $new_y);
- } // End scale
- */
/**
* Scales an image to a percentage of its original size. For example, if
* my image was 640x480 and I called scaleByPercentage(10) then the image
@@ -326,6 +306,7 @@
return PEAR::raiseError("No Save method exists", true);
}
+ /* Methods to add to the driver classes in the future */
function addText()
{
Index: pear/Image_Transform/Image_Transform_GD.php
diff -u pear/Image_Transform/Image_Transform_GD.php:1.1
pear/Image_Transform/Image_Transform_GD.php:1.2
--- pear/Image_Transform/Image_Transform_GD.php:1.1 Thu May 16 14:08:26 2002
+++ pear/Image_Transform/Image_Transform_GD.php Mon May 20 12:28:47 2002
@@ -16,7 +16,7 @@
// | Alan Knowles <alan@akbkhome.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Image_Transform_GD.php,v 1.1 2002/05/16 18:08:26 reywob Exp $
+// $Id: Image_Transform_GD.php,v 1.2 2002/05/20 16:28:47 reywob Exp $
//
// Image Transformation interface using the GD library
//
@@ -135,6 +135,9 @@
$this->old_image = $this->imageHandle;
$this->imageHandle = $new_img;
$this->resized = true;
+
+ $this->new_x = $new_x;
+ $this->new_y = $new_y;
}
/**
Index: pear/Image_Transform/Image_Transform_IM.php
diff -u pear/Image_Transform/Image_Transform_IM.php:1.1
pear/Image_Transform/Image_Transform_IM.php:1.2
--- pear/Image_Transform/Image_Transform_IM.php:1.1 Thu May 16 14:08:26 2002
+++ pear/Image_Transform/Image_Transform_IM.php Mon May 20 12:28:47 2002
@@ -15,7 +15,7 @@
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
-// $Id: Image_Transform_IM.php,v 1.1 2002/05/16 18:08:26 reywob Exp $
+// $Id: Image_Transform_IM.php,v 1.2 2002/05/20 16:28:47 reywob Exp $
//
// Image Transformation interface using command line ImageMagick
//
@@ -56,7 +56,7 @@
$this->image = $image;
$this->_get_size();
// Should the image type be lower or upper case?
- exec($this->lib_path . 'identify -format "%m" ' . $image, $data);
+ exec(IMAGE_TRANSFORM_LIB_PATH . 'identify -format "%m" ' . $image,
$data);
$this->type = strtolower($data[0]);
} // End load
@@ -73,33 +73,10 @@
}
$this->command['resize'] = "-geometry ${new_x}x${new_y}!";
- } // End resize
-
- /*
- function resize($new_x, $new_y = '')
- {
- if ($new_y == '') {
- $new_y = round(($new_x / $this->img_x) * $this->img_y, 0);
- }
- // Record the new size of the image
$this->new_x = $new_x;
- $this->new_y = $new_y;
- $this->command = "convert -geometry ${new_x}x${new_y}!";
-
+ $this->new_y = $new_y;
} // End resize
-
- function scale($size)
- {
- if ($this->img_x >= $this->img_y) {
- $new_x = $size;
- $new_y = round(($new_x / $this->img_x) * $this->img_y, 0);
- } else {
- $new_y = $size;
- $new_x = round(($new_y / $this->img_y) * $this->img_x, 0);
- }
- $this->resize($new_x, $new_y);
- } // End scale
- */
+
/**
* rotate
*
@@ -153,7 +130,7 @@
*/
function save($filename, $quality = 75)
{
- $cmd = 'unlimit;' . $this->lib_path . 'convert ' . implode('
', $this->command) . " -quality $quality " . $this->image . ' ' .
$filename . ' 2>&1';
+ $cmd = 'unlimit;' . IMAGE_TRANSFORM_LIB_PATH . 'convert ' .
implode(' ', $this->command) . " -quality $quality " . $this->image .
' ' . $filename . ' 2>&1';
passthru($cmd);
print $cmd;
} // End save
@@ -170,10 +147,10 @@
{
if ($type == '') {
header('Content-type: image/' . $this->type);
- passthru($this->lib_path . 'convert ' . implode(' ',
$this->command) . " -quality $quality " . $this->image . ' ' .
strtoupper($this->type) . ":-");
+ passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ',
$this->command) . " -quality $quality " . $this->image . ' ' .
strtoupper($this->type) . ":-");
} else {
header('Content-type: image/' . $type);
- passthru($this->lib_path . 'convert ' . implode(' ',
$this->command) . " -quality $quality " . $this->image . ' ' .
strtoupper($type) . ":-");
+ passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ',
$this->command) . " -quality $quality " . $this->image . ' ' .
strtoupper($type) . ":-");
}
}
@@ -195,7 +172,7 @@
*/
function _get_size()
{
- $str = exec($this->lib_path . "identify -format \"%w::%h\" " .
$this->image, $data);
+ $str = exec(IMAGE_TRANSFORM_LIB_PATH . "identify -format \"%w::%h\" " .
$this->image, $data);
$str = split('::', $data[0]);
$this->img_x = $str[0];
$this->img_y = $str[1];
Index: pear/Image_Transform/Image_Transform_NetPBM.php
diff -u pear/Image_Transform/Image_Transform_NetPBM.php:1.2
pear/Image_Transform/Image_Transform_NetPBM.php:1.3
--- pear/Image_Transform/Image_Transform_NetPBM.php:1.2 Fri May 17 11:29:39 2002
+++ pear/Image_Transform/Image_Transform_NetPBM.php Mon May 20 12:28:47 2002
@@ -15,7 +15,7 @@
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
-// $Id: Image_Transform_NetPBM.php,v 1.2 2002/05/17 15:29:39 reywob Exp $
+// $Id: Image_Transform_NetPBM.php,v 1.3 2002/05/20 16:28:47 reywob Exp $
//
// Image Transformation interface using command line NetPBM
//
@@ -68,6 +68,8 @@
}
$this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmscale -width $new_x -height
$new_y";
+ $this->new_x = $new_x;
+ $this->new_y = $new_y;
} // End resize
/**