Source for file NetPBM.php
Documentation is available at NetPBM.php
/***********************************************************************
** Title.........: NetPBM Driver
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** Filename......: NetPBM.php
** Last changed..: 30 Aug 2003
** Notes.........: Orginal is from PEAR
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Peter Bowyer <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
// $Id: NetPBM.php 27 2004-04-01 08:31:57Z Wei Zhuo $
// Image Transformation interface using command line NetPBM
require_once "Transform.php";
* associative array commands to be executed
$this->uid = md5($_SERVER['REMOTE_ADDR']);
} // End function Image_NetPBM
* @return mixed none or a PEAR error object on error
$this->_get_image_details($image);
// there's no technical reason why resize can't be called multiple
// times...it's just silly to do so
"pnmscale -width $new_x -height $new_y";
$this->_set_new_x($new_x);
$this->_set_new_y($new_y);
* @param int $crop_x left column of the image
* @param int $crop_y top row of the image
* @param int $crop_width new cropped image width
* @param int $crop_height new cropped image height
function crop($crop_x, $crop_y, $crop_width, $crop_height)
"pnmcut -left $crop_x -top $crop_y -width $crop_width -height $crop_height";
* @param int $angle The angle to rotate the image through
$this->rotate(- 1* ($angle- 90));
$this->rotate(- 1* ($angle+ 90));
* Flip the image horizontally or vertically
* @param boolean $horizontal true if horizontal flip, vertical otherwise
function flip($horizontal)
* @param float $outputgamma
function gamma($outputgamma = 1.0) {
* @param array options Array contains options
* 'text' // The string to draw
* 'x' // Horizontal position
* 'y' // Vertical Position
* 'font' // Font to be used
* 'size' // Size of the fonts in pixel
* 'resize_first' // Tell if the image has to be resized
* // before drawing the text
$default_params = array('text' => 'This is Text',
'resize_first' => false);
// we ignore 'resize_first' since the more logical approach would be
// for the user to just call $this->_resize() _first_ ;)
$this->command[] = "ppmlabel -angle $angle -colour $color -size "
. "$size -x $x -y ". $y+ $size. " -text \"$text\"";
$type = is_null($type) || $type== ''? $this->type : $type;
$save_type = is_null($save_type) || $save_type== ''? $this->type : $save_type;
//echo "TYPE:". $this->type;
. $type. 'topnm '. $this->image);
$arg = "--quality=$quality";
* @param $filename string the name of the file to write to
* @param string $type (jpeg,png...);
function save($filename, $type= null, $quality = 85)
$cmd = $this->_postProcess('', $quality, $type) . ">$filename";
//if we have windows server
if(isset ($_ENV['OS']) && eregi('window',$_ENV['OS']))
* Display image without saving and lose changes
* @param string $type (jpeg,png...);
function display($type = null, $quality = 75)
header('Content-type: image/' . $type);
// there is no image handle here
|