From 7b24abc7b96b37df8f8523a156da0c6cd96a624b Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Wed, 21 Apr 2004 20:43:23 +0000 Subject: [PATCH] add new UploadImage plugin by Pim Snel ;) --- .../UploadImage/popups/ImageEditor/2x2.gif | Bin 0 -> 286 bytes .../UploadImage/popups/ImageEditor/2x2_w.gif | Bin 0 -> 286 bytes .../UploadImage/popups/ImageEditor/GD.php | 490 ++++++++++ .../UploadImage/popups/ImageEditor/IM.php | 231 +++++ .../popups/ImageEditor/ImageEditor.css | 76 ++ .../popups/ImageEditor/ImageEditor.php | 354 +++++++ .../UploadImage/popups/ImageEditor/NetPBM.php | 254 +++++ .../popups/ImageEditor/Transform.php | 569 +++++++++++ .../popups/ImageEditor/btn_cancel.gif | Bin 0 -> 709 bytes .../UploadImage/popups/ImageEditor/btn_ok.gif | Bin 0 -> 347 bytes .../UploadImage/popups/ImageEditor/crop.gif | Bin 0 -> 185 bytes .../UploadImage/popups/ImageEditor/div.gif | Bin 0 -> 50 bytes .../UploadImage/popups/ImageEditor/hand.gif | Bin 0 -> 109 bytes .../ImageEditor/jscripts/EditorContent.js | 694 +++++++++++++ .../popups/ImageEditor/jscripts/slider.js | 104 ++ .../ImageEditor/jscripts/wz_jsgraphics.js | 921 ++++++++++++++++++ .../popups/ImageEditor/load_image.php | 138 +++ .../UploadImage/popups/ImageEditor/locked.gif | Bin 0 -> 321 bytes .../popups/ImageEditor/man_image.html | 131 +++ .../UploadImage/popups/ImageEditor/rotate.gif | Bin 0 -> 95 bytes .../UploadImage/popups/ImageEditor/ruler.gif | Bin 0 -> 99 bytes .../UploadImage/popups/ImageEditor/save.gif | Bin 0 -> 112 bytes .../UploadImage/popups/ImageEditor/scale.gif | Bin 0 -> 114 bytes .../UploadImage/popups/ImageEditor/spacer.gif | Bin 0 -> 43 bytes .../popups/ImageEditor/t_black.gif | Bin 0 -> 99 bytes .../popups/ImageEditor/t_white.gif | Bin 0 -> 99 bytes .../UploadImage/popups/ImageEditor/test.html | 332 +++++++ .../popups/ImageManager/btnBack.gif | Bin 0 -> 603 bytes .../popups/ImageManager/btnFolderNew.gif | Bin 0 -> 604 bytes .../popups/ImageManager/btnFolderUp.gif | Bin 0 -> 599 bytes .../popups/ImageManager/config.inc.php | 55 ++ .../UploadImage/popups/ImageManager/dots.gif | Bin 0 -> 181 bytes .../popups/ImageManager/edit_active.gif | Bin 0 -> 156 bytes .../popups/ImageManager/edit_pencil.gif | Bin 0 -> 138 bytes .../popups/ImageManager/edit_trash.gif | Bin 0 -> 145 bytes .../popups/ImageManager/folder.gif | Bin 0 -> 1293 bytes .../popups/ImageManager/images.php | 658 +++++++++++++ .../popups/ImageManager/loading.gif | Bin 0 -> 1079 bytes .../popups/ImageManager/locked.gif | Bin 0 -> 401 bytes .../popups/ImageManager/newFolder.html | 89 ++ .../popups/ImageManager/noimages.gif | Bin 0 -> 780 bytes .../popups/ImageManager/thumbs.php | 91 ++ .../popups/ImageManager/unlocked.gif | Bin 0 -> 73 bytes .../popups/ImageManager/uploading.gif | Bin 0 -> 1046 bytes 44 files changed, 5187 insertions(+) create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2_w.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/GD.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/IM.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.css create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/NetPBM.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/Transform.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/btn_cancel.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/btn_ok.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/crop.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/div.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/hand.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/EditorContent.js create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/slider.js create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/wz_jsgraphics.js create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/load_image.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/locked.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/man_image.html create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/rotate.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ruler.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/save.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/scale.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/spacer.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/t_black.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/t_white.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/test.html create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnBack.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnFolderNew.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnFolderUp.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/dots.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_active.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_pencil.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_trash.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/folder.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/loading.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/locked.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/newFolder.html create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/noimages.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/unlocked.gif create mode 100755 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/uploading.gif diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2.gif new file mode 100755 index 0000000000000000000000000000000000000000..2f2ec4aaf44065c63d01ebd1bebf052a109cd2c3 GIT binary patch literal 286 zcmV+(0pb2fNk%w1VPpVg0Du4hnVFgY|NkNR1O*fT0RSuj0001F0Av6F0`&}xr^)LL zpNw?cdUM^n^FM*2M~lA!dTy@MejJ({HOx3&;J@o86t#v(Ct+Xwajotn8trM<24tAba?z5hgj^1AL4im3F kZ+8DyPqY7$kKa$lzZnBd6dVyy-@y(E1vW&u@IwIrJHZi+l>h($ literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2_w.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/2x2_w.gif new file mode 100755 index 0000000000000000000000000000000000000000..9b560a8c57d30827c546d409d3b0610d356b54b6 GIT binary patch literal 286 zcmV+(0pb2fNk%w1VPpVg0Du4hnVFgY|NkNR1O*fT001li0001F0Av6F0`&}xr^)LL zpNw?cdUM^n^FM*2M~lA!dTy@MejJ({HOx3&;J@o86t#v(Ct+Xwajotn8trM<24tAba?z5hgj^1AL4im3F kZ+8DyPqY7$kKa$lzZnBd6dVyy-@y(E1vW&u@IwIrJHQN$lmGw# literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/GD.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/GD.php new file mode 100755 index 0000000000..560e790dc4 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/GD.php @@ -0,0 +1,490 @@ + +** Filename......: GD.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | 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 | +// | Alan Knowles | +// +----------------------------------------------------------------------+ +// +// Usage : +// $img = new Image_Transform_GD(); +// $angle = -78; +// $img->load('magick.png'); +// +// if($img->rotate($angle,array('autoresize'=>true,'color_mask'=>array(255,0,0)))){ +// $img->addText(array('text'=>"Rotation $angle",'x'=>0,'y'=>100,'font'=>'/usr/share/fonts/default/TrueType/cogb____.ttf')); +// $img->display(); +// } else { +// echo "Error"; +// } +// +// +// $Id$ +// +// Image Transformation interface using the GD library +// + +require_once "Transform.php"; + +Class Image_Transform_Driver_GD extends Image_Transform +{ + /** + * Holds the image file for manipulation + */ + var $imageHandle = ''; + + /** + * Holds the original image file + */ + var $old_image = ''; + + /** + * Check settings + * + * @return mixed true or or a PEAR error object on error + * + * @see PEAR::isError() + */ + function Image_Transform_GD() + { + return; + } // End function Image + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + $this->uid = md5($_SERVER['REMOTE_ADDR']); + $this->image = $image; + $this->_get_image_details($image); + $functionName = 'ImageCreateFrom' . $this->type; + $this->imageHandle = $functionName($this->image); + } // End load + + /** + * addText + * + * @param array options Array contains options + * array( + * 'text' The string to draw + * 'x' Horizontal position + * 'y' Vertical Position + * 'Color' Font color + * '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 + * ) + * + * @return none + * @see PEAR::isError() + */ + function addText($params) + { + $default_params = array( + 'text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => array(255,0,0), + 'font' => 'Arial.ttf', + 'size' => '12', + 'angle' => 0, + 'resize_first' => false // Carry out the scaling of the image before annotation? Not used for GD + ); + $params = array_merge($default_params, $params); + extract($params); + + if( !is_array($color) ){ + if ($color[0]=='#'){ + $this->colorhex2colorarray( $color ); + } else { + include_once('Image/Transform/Driver/ColorsDefs.php'); + $color = isset($colornames[$color])?$colornames[$color]:false; + } + } + + $c = imagecolorresolve ($this->imageHandle, $color[0], $color[1], $color[2]); + + if ('ttf' == substr($font, -3)) { + ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text); + } else { + ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text); + } + return true; + } // End addText + + + /** + * Rotate image by the given angle + * Uses a fast rotation algorythm for custom angles + * or lines copy for multiple of 90 degrees + * + * @param int $angle Rotation angle + * @param array $options array( 'autoresize'=>true|false, + * 'color_mask'=>array(r,g,b), named color or #rrggbb + * ) + * @author Pierre-Alain Joye + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function rotate($angle, $options=null) + { + if(function_exists('imagerotate')) { + $white = imagecolorallocate ($this->imageHandle, 255, 255, 255); + $this->imageHandle = imagerotate($this->imageHandle, $angle, $white); + return true; + } + + if ( $options==null ){ + $autoresize = true; + $color_mask = array(255,255,0); + } else { + extract( $options ); + } + + while ($angle <= -45) { + $angle += 360; + } + while ($angle > 270) { + $angle -= 360; + } + + $t = deg2rad($angle); + + if( !is_array($color_mask) ){ + if ($color[0]=='#'){ + $this->colorhex2colorarray( $color_mask ); + } else { + include_once('Image/Transform/Driver/ColorDefs.php'); + $color = isset($colornames[$color_mask])?$colornames[$color_mask]:false; + } + } + + // Do not round it, too much lost of quality + $cosT = cos($t); + $sinT = sin($t); + + $img =& $this->imageHandle; + + $width = $max_x = $this->img_x; + $height = $max_y = $this->img_y; + $min_y = 0; + $min_x = 0; + + $x1 = round($max_x/2,0); + $y1 = round($max_y/2,0); + + if ( $autoresize ){ + $t = abs($t); + $a = round($angle,0); + switch((int)($angle)){ + case 0: + $width2 = $width; + $height2 = $height; + break; + case 90: + $width2 = $height; + $height2 = $width; + break; + case 180: + $width2 = $width; + $height2 = $height; + break; + case 270: + $width2 = $height; + $height2 = $width; + break; + default: + $width2 = (int)(abs(sin($t) * $height + cos($t) * $width)); + $height2 = (int)(abs(cos($t) * $height+sin($t) * $width)); + } + + $width2 -= $width2%2; + $height2 -= $height2%2; + + $d_width = abs($width - $width2); + $d_height = abs($height - $height2); + $x_offset = $d_width/2; + $y_offset = $d_height/2; + $min_x2 = -abs($x_offset); + $min_y2 = -abs($y_offset); + $max_x2 = $width2; + $max_y2 = $height2; + } + + $img2 = @imagecreate($width2,$height2); + + if ( !is_resource($img2) ){ + return false;/*PEAR::raiseError('Cannot create buffer for the rotataion.', + null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/ + } + + $this->img_x = $width2; + $this->img_y = $height2; + + + imagepalettecopy($img2,$img); + + $mask = imagecolorresolve($img2,$color_mask[0],$color_mask[1],$color_mask[2]); + + // use simple lines copy for axes angles + switch((int)($angle)){ + case 0: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $min_x; $x < $max_x; $x++){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c); + } + } + break; + case 90: + imagefill ($img2, 0, 0,$mask); + for ($x = $min_x; $x < $max_x; $x++){ + for ($y=$min_y; $y < $max_y; $y++) { + $c = imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$max_y-$y-1,$x,$c); + } + } + break; + case 180: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $min_x; $x < $max_x; $x++){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2, $max_x2-$x-1, $max_y2-$y-1, $c); + } + } + break; + case 270: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $max_x; $x >= $min_x; $x--){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$y,$max_x-$x-1,$c); + } + } + break; + // simple reverse rotation algo + default: + $i=0; + for ($y = $min_y2; $y < $max_y2; $y++){ + + // Algebra :) + $x2 = round((($min_x2-$x1) * $cosT) + (($y-$y1) * $sinT + $x1),0); + $y2 = round((($y-$y1) * $cosT - ($min_x2-$x1) * $sinT + $y1),0); + + for ($x = $min_x2; $x < $max_x2; $x++){ + + // Check if we are out of original bounces, if we are + // use the default color mask + if ( $x2>=0 && $x2<$max_x && $y2>=0 && $y2<$max_y ){ + $c = imagecolorat ( $img, $x2, $y2); + } else { + $c = $mask; + } + imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c); + + // round verboten! + $x2 += $cosT; + $y2 -= $sinT; + } + } + break; + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $img2; + return true; + } + + + /** + * Resize Action + * + * For GD 2.01+ the new copyresampled function is used + * It uses a bicubic interpolation algorithm to get far + * better result. + * + * @param $new_x int new width + * @param $new_y int new height + * + * @return true on success or pear error + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) { + if ($this->resized === true) { + return false; /*PEAR::raiseError('You have already resized the image without saving it. Your previous resizing will be overwritten', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/ + } + if(function_exists('ImageCreateTrueColor')){ + $new_img =ImageCreateTrueColor($new_x,$new_y); + } else { + $new_img =ImageCreate($new_x,$new_y); + } + if(function_exists('ImageCopyResampled')){ + ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y); + } else { + ImageCopyResized($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y); + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $new_img; + $this->resized = true; + + $this->new_x = $new_x; + $this->new_y = $new_y; + return true; + } + + /** + * Crop the image + * + * @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($new_x, $new_y, $new_width, $new_height) + { + if(function_exists('ImageCreateTrueColor')){ + $new_img =ImageCreateTrueColor($new_width,$new_height); + } else { + $new_img =ImageCreate($new_width,$new_height); + } + if(function_exists('ImageCopyResampled')){ + ImageCopyResampled($new_img, $this->imageHandle, 0, 0, $new_x, $new_y,$new_width,$new_height,$new_width,$new_height); + } else { + ImageCopyResized($new_img, $this->imageHandle, 0, 0, $new_x, $new_y, $new_width,$new_height,$new_width,$new_height); + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $new_img; + $this->resized = true; + + $this->new_x = $new_x; + $this->new_y = $new_y; + return true; + } + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if(!$horizontal) { + $this->rotate(180); + } + + $width = imagesx($this->imageHandle); + $height = imagesy($this->imageHandle); + + for ($j = 0; $j < $height; $j++) { + $left = 0; + $right = $width-1; + + + while ($left < $right) { + //echo " j:".$j." l:".$left." r:".$right."\n
"; + $t = imagecolorat($this->imageHandle, $left, $j); + imagesetpixel($this->imageHandle, $left, $j, imagecolorat($this->imageHandle, $right, $j)); + imagesetpixel($this->imageHandle, $right, $j, $t); + $left++; $right--; + } + + } + + return true; + } + + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma=1.0) { + ImageGammaCorrect($this->imageHandle, 1.0, $outputgamma); + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param $quality int output DPI, default is 85 + * @param $types string define the output format, default + * is the current used format + * + * @return none + */ + function save($filename, $type = '', $quality = 85) + { + $type = $type==''? $this->type : $type; + $functionName = 'image' . $type; + $this->old_image = $this->imageHandle; + $functionName($this->imageHandle, $filename) ; + $this->imageHandle = $this->old_image; + $this->resized = false; + } // End save + + + /** + * Display image without saving and lose changes + * + * @param string type (JPG,PNG...); + * @param int quality 75 + * + * @return none + */ + function display($type = '', $quality = 75) + { + if ($type != '') { + $this->type = $type; + } + $functionName = 'Image' . $this->type; + header('Content-type: image/' . strtolower($this->type)); + $functionName($this->imageHandle, '', $quality); + $this->imageHandle = $this->old_image; + $this->resized = false; + ImageDestroy($this->old_image); + $this->free(); + } + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + if ($this->imageHandle){ + ImageDestroy($this->imageHandle); + } + } + +} // End class ImageGD +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/IM.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/IM.php new file mode 100755 index 0000000000..8cf21ad818 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/IM.php @@ -0,0 +1,231 @@ + +** Filename......: IM.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | 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 | +// +----------------------------------------------------------------------+ +// +// $Id$ +// +// Image Transformation interface using command line ImageMagick +// + +require_once "Transform.php"; + +Class Image_Transform_Driver_IM extends Image_Transform +{ + /** + * associative array commands to be executed + * @var array + */ + var $command = array(); + + /** + * + * + */ + function Image_Transform_Driver_IM() + { + return true; + } // End Image_IM + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + + $this->uid = md5($_SERVER['REMOTE_ADDR']); + /*if (!file_exists($image)) { + return PEAR::raiseError('The image file ' . $image . ' does\'t exist', true); + }*/ + $this->image = $image; + $this->_get_image_details($image); + } // End load + + /** + * Resize Action + * + * @param int new_x new width + * @param int new_y new height + * + * @return none + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) + { + /*if (isset($this->command['resize'])) { + return PEAR::raiseError("You cannot scale or resize an image more than once without calling save or display", true); + }*/ + $this->command['resize'] = "-geometry ${new_x}x${new_y}!"; + + $this->new_x = $new_x; + $this->new_y = $new_y; + } // End resize + + /** + * Crop the image + * + * @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) + { + $this->command['crop'] = "-crop {$crop_width}x{$crop_height}+{$crop_x}+{$crop_y}"; + } + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if($horizontal) + $this->command['flop'] = "-flop"; + else + $this->command['flip'] = "-flip"; + } + /** + * rotate + * + * @param int angle rotation angle + * @param array options no option allowed + * + */ + function rotate($angle, $options=null) + { + if ('-' == $angle{0}) { + $angle = 360 - substr($angle, 1); + } + $this->command['rotate'] = "-rotate $angle"; + } // End rotate + + /** + * addText + * + * @param array options Array contains options + * array( + * 'text' The string to draw + * 'x' Horizontal position + * 'y' Vertical Position + * 'Color' Font color + * '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 + * ) + * + * @return none + * @see PEAR::isError() + */ + function addText($params) + { + $default_params = array( + 'text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => 'red', + 'font' => 'Arial.ttf', + 'resize_first' => false // Carry out the scaling of the image before annotation? + ); + $params = array_merge($default_params, $params); + extract($params); + if (true === $resize_first) { + // Set the key so that this will be the last item in the array + $key = 'ztext'; + } else { + $key = 'text'; + } + $this->command[$key] = "-font $font -fill $color -draw 'text $x,$y \"$text\"'"; + // Producing error: gs: not found gs: not found convert: Postscript delegate failed [No such file or directory]. + } // End addText + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma=1.0) { + $this->command['gamma'] = "-gamma $outputgamma"; + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param $quality quality image dpi, default=75 + * @param $type string (JPG,PNG...) + * + * @return none + */ + function save($filename, $type='', $quality = 85) + { + $type == '' ? $this->type : $type; + $cmd = '' . IMAGE_TRANSFORM_LIB_PATH . 'convert" ' . implode(' ', $this->command) . " -quality $quality " . ($this->image) . ' ' . ($filename) . ' 2>&1'; + + //echo $cmd; + exec($cmd); + } // End save + + /** + * Display image without saving and lose changes + * + * @param string type (JPG,PNG...); + * @param int quality 75 + * + * @return none + */ + function display($type = '', $quality = 75) + { + if ($type == '') { + header('Content-type: image/' . $this->type); + passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($this->type) . ":-"); + } else { + header('Content-type: image/' . $type); + passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($type) . ":-"); + } + } + + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + return true; + } + +} // End class ImageIM +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.css b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.css new file mode 100755 index 0000000000..7cefe46cd7 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.css @@ -0,0 +1,76 @@ +.icons { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + border: 1px solid #EEEEFF; + -Moz-Border-Radius: 6px 6px 6px 6px; +} + +body, td, p { + font: 11px Tahoma,Verdana,sans-serif; +} +.iconsOver { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + background-color: #F9F9FF; + border: 1px solid #666699; + -Moz-Border-Radius: 6px 6px 6px 6px; +} +.topBar { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; +} +.iconsSel { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + border: 1px solid #666699; + -Moz-Border-Radius: 6px 6px 6px 6px; +} +.iconText { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-decoration: none; + text-align: center; +} +.measureStats{ + width: 50px; +} + +#slidercasing { + /*border:1px solid #CCCCCC; + background-color:#FFFFFF;*/ + width:100px; + height:5px; + position:relative; + z-index:4; + padding:10px; +} + + +#slidertrack { + position:relative; + border:1px solid #CCCCCC; + background-color:#FFFFCC; + z-index:5; + height:5px; +} + + +#sliderbar { + position:absolute; + z-index:6; + border:1px solid #CCCCCC; + background-color:#DDDDDD; + width:15px; + padding:0px; + height:20px; + cursor: pointer; + top:2px; +} + +select, input, button { font: 11px Tahoma,Verdana,sans-serif; } diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.php new file mode 100755 index 0000000000..92678ef8e8 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ImageEditor.php @@ -0,0 +1,354 @@ + +** Filename......: ImageEditor.php +** Last changed..: 31 Aug 2003 +** Notes.........: Configuration in config.inc.php +**/ + $image = ''; + + if(isset($_GET['img'])) + { + $image = $_GET['img']; + $path_info = pathinfo(urldecode($image)); + } +?> + + + Editing: <? echo $path_info['basename']; ?> + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
Crop
+ Crop
Resize
+ Resize
Rotate
+ Rotate
Measure
+ Measure
Marker
+ Marker
Save
+ Save
+
+ +
+ + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/NetPBM.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/NetPBM.php new file mode 100755 index 0000000000..f3f6513c0e --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/NetPBM.php @@ -0,0 +1,254 @@ + +** Filename......: NetPBM.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | 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 | +// +----------------------------------------------------------------------+ +// +// $Id$ +// +// Image Transformation interface using command line NetPBM + +require_once "Transform.php"; + +Class Image_Transform_Driver_NetPBM extends Image_Transform +{ + + /** + * associative array commands to be executed + * @var array + */ + var $command = array(); + + /** + * Class Constructor + */ + function Image_Transform_Driver_NetPBM() + { + $this->uid = md5($_SERVER['REMOTE_ADDR']); + + return true; + } // End function Image_NetPBM + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + //echo $image; + $this->image = $image; + $this->_get_image_details($image); + } // End load + + /** + * Resizes the image + * + * @return none + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) + { + // there's no technical reason why resize can't be called multiple + // times...it's just silly to do so + + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . + "pnmscale -width $new_x -height $new_y"; + + $this->_set_new_x($new_x); + $this->_set_new_y($new_y); + } // End resize + + /** + * Crop the image + * + * @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) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . + "pnmcut -left $crop_x -top $crop_y -width $crop_width -height $crop_height"; + } + + /** + * Rotates the image + * + * @param int $angle The angle to rotate the image through + */ + function rotate($angle) + { + $angle = -1*floatval($angle); + + if($angle > 90) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias 90"; + $this->rotate(-1*($angle-90)); + } + else if ($angle < -90) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias -90"; + $this->rotate(-1*($angle+90)); + } + else + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias $angle"; + } // End rotate + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if($horizontal) + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -lr"; + else + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -tb"; + } + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma = 1.0) { + $this->command[13] = IMAGE_TRANSFORM_LIB_PATH . "pnmgamma $outputgamma"; + } + + /** + * adds text to an image + * + * @param array options Array contains options + * array( + * 'text' // The string to draw + * 'x' // Horizontal position + * 'y' // Vertical Position + * 'Color' // Font color + * '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 + * ) + * + * @return none + */ + function addText($params) + { + $default_params = array('text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => 'red', + 'font' => 'Arial.ttf', + 'size' => '12', + 'angle' => 0, + 'resize_first' => false); + // we ignore 'resize_first' since the more logical approach would be + // for the user to just call $this->_resize() _first_ ;) + extract(array_merge($default_params, $params)); + $this->command[] = "ppmlabel -angle $angle -colour $color -size " + ."$size -x $x -y ".$y+$size." -text \"$text\""; + } // End addText + + function _postProcess($type, $quality, $save_type) + { + $type = is_null($type) || $type==''? $this->type : $type; + $save_type = is_null($save_type) || $save_type==''? $this->type : $save_type; + //echo "TYPE:". $this->type; + array_unshift($this->command, IMAGE_TRANSFORM_LIB_PATH + . $type.'topnm '. $this->image); + $arg = ''; + switch(strtolower($save_type)){ + case 'gif': + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmquant 256"; + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type"; + break; + case 'jpg': + case 'jpeg': + $arg = "--quality=$quality"; + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type $arg"; + break; + default: + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmto$save_type $arg"; + break; + } // switch + return implode('|', $this->command); + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param string $type (jpeg,png...); + * @param int $quality 75 + * @return none + */ + function save($filename, $type=null, $quality = 85) + { + $cmd = $this->_postProcess('', $quality, $type) . ">$filename"; + + //If you are using windows, you need the following line. + //$cmd = ereg_replace('/','\\',$cmd); + //echo $cmd."##"; + system($cmd); + $this->command = array(); + } // End save + + + /** + * Display image without saving and lose changes + * + * @param string $type (jpeg,png...); + * @param int $quality 75 + * @return none + */ + function display($type = null, $quality = 75) + { + header('Content-type: image/' . $type); + $cmd = $this->_postProcess($type, $quality); + + passthru($cmd); + $this->command = array(); + } + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + // there is no image handle here + return true; + } + + +} // End class ImageIM +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/Transform.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/Transform.php new file mode 100755 index 0000000000..0daa07216d --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/Transform.php @@ -0,0 +1,569 @@ + +** Filename......: Transform.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR + + Added a few extra, + - create unique filename in a particular directory, + used for temp image files. + - added cropping to GD, NetPBM, ImageMagick +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | 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 | +// | Alan Knowles | +// | Vincent Oostindie | +// +----------------------------------------------------------------------+ +// +// $Id$ +// +// Image Transformation interface +// + + +/** + * The main "Image_Resize" class is a container and base class which + * provides the static methods for creating Image objects as well as + * some utility functions (maths) common to all parts of Image Resize. + * + * The object model of DB is as follows (indentation means inheritance): + * + * Image_Resize The base for each Image implementation. Provides default + * | implementations (in OO lingo virtual methods) for + * | the actual Image implementations as well as a bunch of + * | maths methods. + * | + * +-Image_GD The Image implementation for the PHP GD extension . Inherits + * Image_Resize + * When calling DB::setup for GD images the object returned is an + * instance of this class. + * + * @package Image Resize + * @version 1.00 + * @author Peter Bowyer + * @since PHP 4.0 + */ +Class Image_Transform +{ + /** + * Name of the image file + * @var string + */ + var $image = ''; + /** + * Type of the image file (eg. jpg, gif png ...) + * @var string + */ + var $type = ''; + /** + * Original image width in x direction + * @var int + */ + var $img_x = ''; + /** + * Original image width in y direction + * @var int + */ + var $img_y = ''; + /** + * New image width in x direction + * @var int + */ + var $new_x = ''; + /** + * New image width in y direction + * @var int + */ + var $new_y = ''; + /** + * Path the the library used + * e.g. /usr/local/ImageMagick/bin/ or + * /usr/local/netpbm/ + */ + var $lib_path = ''; + /** + * Flag to warn if image has been resized more than once before displaying + * or saving. + */ + var $resized = false; + + + var $uid = ''; + + var $lapse_time =900; //15 mins + + /** + * Create a new Image_resize object + * + * @param string $driver name of driver class to initialize + * + * @return mixed a newly created Image_Transform object, or a PEAR + * error object on error + * + * @see PEAR::isError() + * @see Image_Transform::setOption() + */ + function &factory($driver) + { + if ('' == $driver) { + die("No image library specified... aborting. You must call ::factory() with one parameter, the library to load."); + + } + $this->uid = md5($_SERVER['REMOTE_ADDR']); + + include_once "$driver.php"; + + $classname = "Image_Transform_Driver_{$driver}"; + $obj =& new $classname; + return $obj; + } + + + /** + * Resize the Image in the X and/or Y direction + * If either is 0 it will be scaled proportionally + * + * @access public + * + * @param mixed $new_x (0, number, percentage 10% or 0.1) + * @param mixed $new_y (0, number, percentage 10% or 0.1) + * + * @return mixed none or PEAR_error + */ + function resize($new_x = 0, $new_y = 0) + { + // 0 means keep original size + $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. + return $this->_resize($new_x, $new_y); + } // End resize + + + /** + * Scale the image to have the max x dimension specified. + * + * @param int $new_x Size to scale X-dimension to + * @return none + */ + function scaleMaxX($new_x) + { + $new_y = round(($new_x / $this->img_x) * $this->img_y, 0); + return $this->_resize($new_x, $new_y); + } // End resizeX + + /** + * Scale the image to have the max y dimension specified. + * + * @access public + * @param int $new_y Size to scale Y-dimension to + * @return none + */ + function scaleMaxY($new_y) + { + $new_x = round(($new_y / $this->img_y) * $this->img_x, 0); + return $this->_resize($new_x, $new_y); + } // End resizeY + + /** + * Scale Image to a maximum or percentage + * + * @access public + * @param mixed (number, percentage 10% or 0.1) + * @return mixed none or PEAR_error + */ + function scale($size) + { + if ((strlen($size) > 1) && (substr($size,-1) == '%')) { + return $this->scaleByPercentage(substr($size, 0, -1)); + } elseif ($size < 1) { + return $this->scaleByFactor($size); + } else { + return $this->scaleByLength($size); + } + } // 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 + * would be resized to 64x48 + * + * @access public + * @param int $size Percentage of original size to scale to + * @return none + */ + function scaleByPercentage($size) + { + return $this->scaleByFactor($size / 100); + } // End scaleByPercentage + + /** + * Scales an image to a factor of its original size. For example, if + * my image was 640x480 and I called scaleByFactor(0.5) then the image + * would be resized to 320x240. + * + * @access public + * @param float $size Factor of original size to scale to + * @return none + */ + function scaleByFactor($size) + { + $new_x = round($size * $this->img_x, 0); + $new_y = round($size * $this->img_y, 0); + return $this->_resize($new_x, $new_y); + } // End scaleByFactor + + /** + * Scales an image so that the longest side has this dimension. + * + * @access public + * @param int $size Max dimension in pixels + * @return none + */ + function scaleByLength($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); + } + return $this->_resize($new_x, $new_y); + } // End scaleByLength + + + /** + * + * @access public + * @return void + */ + function _get_image_details($image) + { + //echo $image; + $data = @GetImageSize($image); + #1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order, + # 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC + if (is_array($data)){ + switch($data[2]){ + case 1: + $type = 'gif'; + break; + case 2: + $type = 'jpeg'; + break; + case 3: + $type = 'png'; + break; + case 4: + $type = 'swf'; + break; + case 5: + $type = 'psd'; + case 6: + $type = 'bmp'; + case 7: + case 8: + $type = 'tiff'; + default: + echo("We do not recognize this image format"); + } + $this->img_x = $data[0]; + $this->img_y = $data[1]; + $this->type = $type; + + return true; + } else { + echo("Cannot fetch image or images details."); + return null; + } + /* + $output = array( + 'width' => $data[0], + 'height' => $data[1], + 'type' => $type + ); + return $output; + */ + } + + + /** + * Parse input and convert + * If either is 0 it will be scaled proportionally + * + * @access private + * + * @param mixed $new_size (0, number, percentage 10% or 0.1) + * @param int $old_size + * + * @return mixed none or PEAR_error + */ + function _parse_size($new_size, $old_size) + { + if ('%' == $new_size) { + $new_size = str_replace('%','',$new_size); + $new_size = $new_size / 100; + } + if ($new_size > 1) { + return (int) $new_size; + } elseif ($new_size == 0) { + return (int) $old_size; + } else { + return (int) round($new_size * $old_size, 0); + } + } + + + function uniqueStr() + { + return substr(md5(microtime()),0,6); + } + + //delete old tmp files, and allow only 1 file per remote host. + function cleanUp($id, $dir) + { + $d = dir($dir); + $id_length = strlen($id); + + while (false !== ($entry = $d->read())) { + if (is_file($dir.'/'.$entry) && substr($entry,0,1) == '.' && !ereg($entry, $this->image)) + { + //echo filemtime($this->directory.'/'.$entry)."
"; + //echo time(); + + if (filemtime($dir.'/'.$entry) + $this->lapse_time < time()) + unlink($dir.'/'.$entry); + + if (substr($entry, 1, $id_length) == $id) + { + if (is_file($dir.'/'.$entry)) + unlink($dir.'/'.$entry); + } + } + } + $d->close(); + } + + + function createUnique($dir) + { + $unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type; + + //make sure the the unique temp file does not exists + while (file_exists($dir.$unique_str)) + { + $unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type; + } + + $this->cleanUp($this->uid, $dir); + + return $unique_str; + } + + + /** + * Set the image width + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_img_x($size) + { + $this->img_x = $size; + } + + /** + * Set the image height + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_img_y($size) + { + $this->img_y = $size; + } + + /** + * Set the image width + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_new_x($size) + { + $this->new_x = $size; + } + + /** + * Set the image height + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_new_y($size) + { + $this->new_y = $size; + } + + /** + * Get the type of the image being manipulated + * + * @return string $this->type the image type + */ + function getImageType() + { + return $this->type; + } + + /** + * + * @access public + * @return string web-safe image type + */ + function getWebSafeFormat() + { + switch($this->type){ + case 'gif': + case 'png': + return 'png'; + break; + default: + return 'jpeg'; + } // switch + } + + /** + * Place holder for the real resize method + * used by extended methods to do the resizing + * + * @access private + * @return PEAR_error + */ + function _resize() { + return null; //PEAR::raiseError("No Resize method exists", true); + } + + /** + * Place holder for the real load method + * used by extended methods to do the resizing + * + * @access public + * @return PEAR_error + */ + function load($filename) { + return null; //PEAR::raiseError("No Load method exists", true); + } + + /** + * Place holder for the real display method + * used by extended methods to do the resizing + * + * @access public + * @param string filename + * @return PEAR_error + */ + function display($type, $quality) { + return null; //PEAR::raiseError("No Display method exists", true); + } + + /** + * Place holder for the real save method + * used by extended methods to do the resizing + * + * @access public + * @param string filename + * @return PEAR_error + */ + function save($filename, $type, $quality) { + return null; //PEAR::raiseError("No Save method exists", true); + } + + /** + * Place holder for the real free method + * used by extended methods to do the resizing + * + * @access public + * @return PEAR_error + */ + function free() { + return null; //PEAR::raiseError("No Free method exists", true); + } + + /** + * Reverse of rgb2colorname. + * + * @access public + * @return PEAR_error + * + * @see rgb2colorname + */ + function colorhex2colorarray($colorhex) { + $r = hexdec(substr($colorhex, 1, 2)); + $g = hexdec(substr($colorhex, 3, 2)); + $b = hexdec(substr($colorhex, 4, 2)); + return array($r,$g,$b); + } + + /** + * Reverse of rgb2colorname. + * + * @access public + * @return PEAR_error + * + * @see rgb2colorname + */ + function colorarray2colorhex($color) { + $color = '#'.dechex($color[0]).dechex($color[1]).dechex($color[2]); + return strlen($color)>6?false:$color; + } + + + /* Methods to add to the driver classes in the future */ + function addText() + { + return null; //PEAR::raiseError("No addText method exists", true); + } + + function addDropShadow() + { + return null; //PEAR::raiseError("No AddDropShadow method exists", true); + } + + function addBorder() + { + return null; //PEAR::raiseError("No addBorder method exists", true); + } + + function crop() + { + return null; //PEAR::raiseError("No crop method exists", true); + } + + function flip() + { + return null; + } + + function gamma() + { + return null; //PEAR::raiseError("No gamma method exists", true); + } +} +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/btn_cancel.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/btn_cancel.gif new file mode 100755 index 0000000000000000000000000000000000000000..cf59af75d6ea02109eecab27c1bb80d2bf741956 GIT binary patch literal 709 zcmZ?wbhEHblw*)%c*ekRfQjkbw{K_8oY}E>@to-B^=4+D8XK?j^S=lSyLa#2b1SQv z#>NlY+ph!%|605D``x=|7#NBe#^4wn<8U($>Ct^X41}hv(0qZ`IPeuyEm-&70r6 zc=5icXJ=&O+bdV@#>T#kiTV5f{doa_z4G!8{rt8%IelEb__Czr9v7E~MnyCuPJpqBct5#i)i~AH1@bcWbpG%kSTE2X%mDTr_mhYOHKQCW?>+F17 zQu0e&+>4$b2GW7zPZm}Y25|-*kXBHfFtGn`5N~R3X>Duo=Fw*EFmcjkahp^F zOUq=txGAowp>i6^ZkA#Gx%?Adb&^c2q*Ybjy|Yz>Qu6~|8?z-}PcHK0yotJViKAZgI=i>#tfPTia%LcMHmkR+M)!kzC4;zy7Ep!3hLFZeln_jd6=xTeoD(K2&A_rGjGK2u Txbno99XogJ-m`ayBZD;nUI3D$ literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/crop.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/crop.gif new file mode 100755 index 0000000000000000000000000000000000000000..380f9ce21df6cd648e3b655af865657ffa25b5d7 GIT binary patch literal 185 zcmZ?wbhEHb6k!ly*v!BX99;VU|NomeZ>FWqOiu2stXx=CH9tDK1<38~T~|~zJu0d$ zF|n$Hy}}99C#Ni@F>q)e?1}T1h~pYsNyu kganTE);Zgm8Kwv?-Z;^uOoO?+UW})yS=6z;S&+dR0EF{LApigX literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/div.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/div.gif new file mode 100755 index 0000000000000000000000000000000000000000..b9940cb09f81a51fe5eebb95bb0556a81cef67e4 GIT binary patch literal 50 zcmZ?wbhEHbWMYtGXkcL2zyIm~|Nj+#vapCS{AbW%00NK<0~4o9&+?P6dFT7EGFSru DgWnFA literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/hand.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/hand.gif new file mode 100755 index 0000000000000000000000000000000000000000..0fcb538fe016d9693f58bba8bdb5af33eafd0259 GIT binary patch literal 109 zcmV-z0FwVlNk%w1VH5xq0FeLyW@efH|Nq(9*#H0lA^8La6aWDLEC2ui02BZe0006$ zjE||yjR4$>F~G_yG`i_-30MMt)>3kuFrA9Vs@C|%?p@n>rpsQxBME@P1Aypz3>~zP Pq;(W literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/EditorContent.js b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/EditorContent.js new file mode 100755 index 0000000000..b025c05343 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/EditorContent.js @@ -0,0 +1,694 @@ +/*********************************************************************** +** Title.........: Online Image Editor Interface +** Version.......: 1.0 +** Author........: Xiang Wei ZHUO +** Filename......: EditorContents.js +** Last changed..: 31 Aug 2003 +** Notes.........: Handles most of the interface routines for the ImageEditor. +**/ + + +function MM_findObj(n, d) { //v4.01 + var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { + d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} + if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i-1 && navigator.appVersion.indexOf("Mac")>-1)) { + ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top); + }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10; + a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b; + //alert(event.clientX); + if (event == null) x=document.body.scrollLeft + bx; + else x=document.body.scrollLeft + event.clientX + bx; + if (event == null) y=document.body.scrollTop; + else y=document.body.scrollTop + event.clientY;}} + }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd=""; + for(var s=0;s4){xx+="px";yy+="px";} + if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){ + xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin); + xx+="px";yy+="px";}e.left=xx;e.top=yy;} + pic_x = parseInt(xx); pic_y = parseInt(yy); + //alert(xx+":"+yy); + } +} + +var ie=document.all +var ns6=document.getElementById&&!document.all + +var dragapproved=false +var z,x,y,status, ant, canvas, content, pic_width, pic_height, image, resizeHandle, oa_w, oa_h, oa_x, oa_y, mx2, my2; + + +function init_resize() +{ + if(mode == "scale") + { + P7_Snap('theImage','ant',0,0); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + if (ant == null) + ant = MM_findObj("ant"); + + ant.style.left = pic_x; ant.style.top = pic_y; + ant.style.width = pic_width; ant.style.height = pic_height; + ant.style.visibility = "visible"; + + drawBoundHandle(); + jg_doc.paint(); + } +} + +function init() +{ + init_crop(); + init_resize(); + var markerImg = MM_findObj('markerImg', window.top.document); + + if (markerImg.src.indexOf("t_white.gif")>0) + toggleMarker() ; +} + +function init_crop() +{ + //if(mode == "crop") { + P7_Snap('theImage','ant',0,0); + //} +} + +function setMode(newMode) +{ + mode = newMode; + reset(); +} + +function reset() +{ + if (ant == null) + ant = MM_findObj("ant"); + + ant.style.visibility = "hidden"; + ant.style.left = 0; + ant.style.top = 0; + ant.style.width = 0; + ant.style.height = 0; + + mx2 = null; + my2 = null; + + jg_doc.clear(); + if(mode != 'measure') + showStatus(); + + if(mode == "scale") { + init_resize(); + } + + P7_Snap('theImage','ant',0,0); +} + +function toggleMarker() +{ + //alert("Toggle"); + if (ant == null) + ant = MM_findObj("ant"); + + if(ant.className=="selection") + ant.className="selectionWhite"; + else + ant.className="selection"; + + if (jg_doc.getColor() == "#000000") + jg_doc.setColor("#FFFFFF"); + else + jg_doc.setColor("#000000"); + + drawBoundHandle + jg_doc.paint(); +} + + +function move(e) +{ + if (dragapproved) + { + //z.style.left=ns6? temp1+e.clientX-x: temp1+event.clientX-x + //z.style.top=ns6? temp2+e.clientY-y : temp2+event.clientY-y + var w = ns6? temp1+e.clientX - x : temp1+event.clientX - x; + var h = ns6? temp2+e.clientY - y : temp2+event.clientY - y; + + //alert(canvas.style.left); + /*if (status !=null) + { + status.innerHTML = "x:"+x+" y:"+y+" w:"+w+" h:"+h+" can_h:"+pic_height; + status.innerHTML += " can_w:"+pic_width+" px:"+pic_x+" py:"+pic_y; + status.innerHTML += " pix:"+image.style.left+" piy:"+image.style.top+" obj:"+obj.id; + }*/ + + /*jg_doc.clear(); + jg_doc.fillRectPattern(0,0,Math.abs(w),Math.abs(h),pattern); + jg_doc.paint(); +*/ + if (ant != null) + { + if (w >= 0) + { + ant.style.left = x; + ant.style.width = w; + } + else + { + ant.style.left = x+w; + ant.style.width = -1*w; + } + + if (h >= 0) + { + ant.style.top = y; + ant.style.height = h; + } + else + { + ant.style.top = y+h; + ant.style.height = -1*h + } + } + + showStatus(); + return false + } +} + +function moveContent(e) +{ + if (dragapproved) + { + + var dx =ns6? oa_x + e.clientX-x: oa_x + event.clientX-x + var dy =ns6? oa_y + e.clientY-y : oa_y + event.clientY-y + + + /*if (status !=null) + { + status.innerHTML = "x:"+x+" y:"+y+" dx:"+dx+" dy:"+dy; + }*/ + + ant.style.left = dx; + ant.style.top = dy; + + showStatus(); + + return false; + } +} + +function moveHandle(e) +{ + if (dragapproved) + { + var w = ns6? e.clientX - x : event.clientX - x; + var h = ns6? e.clientY - y : event.clientY - y; + + switch(resizeHandle) + { + + case "s-resize": + if (oa_h + h >= 0) + ant.style.height = oa_h + h; + break; + case "e-resize": + if(oa_w + w >= 0) + ant.style.width = oa_w + w; + break; + case "n-resize": + if (oa_h - h >= 0) + { + ant.style.top = oa_y + h; + ant.style.height = oa_h - h; + } + break; + case "w-resize": + if(oa_w - w >= 0) { + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + }break; + case "nw-resize": + if(oa_h - h >= 0 && oa_w - w >= 0) { + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + ant.style.top = oa_y + h; + ant.style.height = oa_h - h; + } + break; + case "ne-resize": + if (oa_h - h >= 0 && oa_w + w >= 0){ + ant.style.top = oa_y + h; + ant.style.height = oa_h - h; + ant.style.width = oa_w + w; + } + break; + case "se-resize": + if (oa_h + h >= 0 && oa_w + w >= 0) + { + ant.style.height = oa_h + h; + ant.style.width = oa_w + w; + } + break; + case "sw-resize": + if (oa_h + h >= 0 && oa_w - w >= 0) + { + ant.style.height = oa_h + h; + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + } + } + + showStatus(); + return false; + + } +} + +function drags(e) +{ + if (!ie&&!ns6) + return + + var firedobj=ns6? e.target : event.srcElement + var topelement=ns6? "HTML" : "BODY" + + while (firedobj.tagName!=topelement&& + !(firedobj.className=="crop" + || firedobj.className=="handleBox" + || firedobj.className=="selection" || firedobj.className=="selectionWhite")) + { + firedobj=ns6? firedobj.parentNode : firedobj.parentElement + } + + if(firedobj.className=="handleBox") { + + if(content != null) { + if(content.width != null && content.height != null) { + content.width = 0; + content.height = 0; + } + //alert(content.width+":"+content.height); + } + resizeHandle = firedobj.id; + + /*if(status!=null) { + status.innerHTML = " obj:"+firedobj.id; + }*/ + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + oa_w = parseInt(ant.style.width); + oa_h = parseInt(ant.style.height); + oa_x = parseInt(ant.style.left); + oa_y = parseInt(ant.style.top); + + dragapproved=true + document.onmousemove=moveHandle; + return false; + } + else + if((firedobj.className == "selection" || firedobj.className=="selectionWhite")&& mode == "crop") { + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + oa_x = parseInt(ant.style.left); + oa_y = parseInt(ant.style.top); + + dragapproved=true + document.onmousemove=moveContent; + return false; + } + else + if (firedobj.className=="crop" && mode == "crop") + { + if(content != null) { + if(content.width != null && content.height != null) { + content.width = 0; + content.height = 0; + } + //alert(content.width+":"+content.height); + } + + if (status == null) + status = MM_findObj("status"); + + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + if(content == null) { + content = MM_findObj("cropContent"); + } + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + ant.style.visibility = "visible"; + + obj = firedobj; + dragapproved=true + z=firedobj + temp1=parseInt(z.style.left+0) + temp2=parseInt(z.style.top+0) + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + document.onmousemove=move + return false + } + else if(firedobj.className=="crop" && mode == "measure") { + + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + //jg_doc.draw + dragapproved=true + document.onmousemove=measure + + return false + } +} + +function measure(e) +{ + if (dragapproved) + { + mx2 = ns6? e.clientX : event.clientX; + my2 = ns6? e.clientY : event.clientY; + + jg_doc.clear(); + jg_doc.setStroke(Stroke.DOTTED); + jg_doc.drawLine(x,y,mx2,my2); + jg_doc.paint(); + showStatus(); + return false; + } +} + +function setMarker(nx,ny,nw,nh) +{ + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + if(content == null) { + content = MM_findObj("cropContent"); + } + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + ant.style.visibility = "visible"; + + nx = pic_x + nx; + ny = pic_y + ny; + + if (nw >= 0) + { + ant.style.left = nx; + ant.style.width = nw; + } + else + { + ant.style.left = nx+nw; + ant.style.width = -1*nw; + } + + if (nh >= 0) + { + ant.style.top = ny; + ant.style.height = nh; + } + else + { + ant.style.top = ny+nh; + ant.style.height = -1*nh + } + + +} + +function max(x,y) +{ + if(y > x) + return x; + else + return y; +} + +function drawBoundHandle() +{ + if(ant == null || ant.style == null) + return false; + + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + + jg_doc.drawHandle(ax-15,ay-15,30,30,"nw-resize"); //upper left + jg_doc.drawHandle(ax-15,ay+ah-15,30,30,"sw-resize"); //lower left + jg_doc.drawHandle(ax+aw-15,ay-15,30,30,"ne-resize"); //upper right + jg_doc.drawHandle(ax+aw-15,ay+ah-15,30,30,"se-resize"); //lower right + + jg_doc.drawHandle(ax+max(15,aw/10),ay-8,aw-2*max(15,aw/10),8,"n-resize"); //top middle + jg_doc.drawHandle(ax+max(15,aw/10),ay+ah,aw-2*max(15,aw/10),8,"s-resize"); //bottom middle + jg_doc.drawHandle(ax-8, ay+max(15,ah/10),8,ah-2*max(15,ah/10),"w-resize"); //left middle + jg_doc.drawHandle(ax+aw, ay+max(15,ah/10),8,ah-2*max(15,ah/10),"e-resize"); //right middle + + + + jg_doc.drawHandleBox(ax-4,ay-4,8,8,"nw-resize"); //upper left + jg_doc.drawHandleBox(ax-4,ay+ah-4,8,8,"sw-resize"); //lower left + jg_doc.drawHandleBox(ax+aw-4,ay-4,8,8,"ne-resize"); //upper right + jg_doc.drawHandleBox(ax+aw-4,ay+ah-4,8,8,"se-resize"); //lower right + + jg_doc.drawHandleBox(ax+aw/2-4,ay-4,8,8,"n-resize"); //top middle + jg_doc.drawHandleBox(ax+aw/2-4,ay+ah-4,8,8,"s-resize"); //bottom middle + jg_doc.drawHandleBox(ax-4, ay+ah/2-4,8,8,"w-resize"); //left middle + jg_doc.drawHandleBox(ax+aw-4, ay+ah/2-4,8,8,"e-resize"); //right middle + + //jg_doc.paint(); +} + +function showStatus() +{ + if(ant == null || ant.style == null) { + return false; + } + + if(mode == "measure") { + //alert(pic_x); + mx1 = x - pic_x; + my1 = y - pic_y; + + mw = mx2 - x; + mh = my2 - y; + + md = parseInt(Math.sqrt(mw*mw + mh*mh)*100)/100; + + ma = (Math.atan(-1*mh/mw)/Math.PI)*180; + if(mw < 0 && mh < 0) + ma = ma+180; + + if (mw <0 && mh >0) + ma = ma - 180; + + ma = parseInt(ma*100)/100; + + if (m_sx != null && !isNaN(mx1)) + m_sx.innerHTML = mx1+" px"; + if (m_sy != null && !isNaN(my1)) + m_sy.innerHTML = my1+" px"; + if(m_w != null && !isNaN(mw)) + m_w.innerHTML = mw + " px"; + if(m_h != null && !isNaN(mh)) + m_h.innerHTML = mh + " px"; + + if(m_d != null && !isNaN(md)) + m_d.innerHTML = md + " px"; + if(m_a != null && !isNaN(ma)) + m_a.innerHTML = ma + "° "; + + if(r_ra != null &&!isNaN(ma)) + r_ra.value = ma; + + //alert("mx1:"+mx1+" my1"+my1); + return false; + } + + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + + var cx = ax-pic_x<0?0:ax-pic_x; + var cy = ay-pic_y<0?0:ay-pic_y; + cx = cx>pic_width?pic_width:cx; + cy = cy>pic_height?pic_height:cy; + + var cw = ax-pic_x>0?aw:aw-(pic_x-ax); + var ch = ay-pic_y>0?ah:ah-(pic_y-ay); + + ch = ay+ah0 && s_sh.value.indexOf('%')>0) + { + sw = cw/pic_width; + sh = ch/pic_height; + } + if (s_sw != null) + s_sw.value = sw; + if (s_sh != null) + s_sh.value = sh; + } + +} + +function dragStopped() +{ + dragapproved=false; + + if(ant == null || ant.style == null) { + return false; + } + + if(mode == "measure") { + jg_doc.drawLine(x-4,y,x+4,y); + jg_doc.drawLine(x,y-4,x,y+4); + jg_doc.drawLine(mx2-4,my2,mx2+4,my2); + jg_doc.drawLine(mx2,my2-4,mx2,my2+4); + + jg_doc.paint(); + showStatus(); + return false; + } + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + jg_doc.clear(); + + if(content != null) { + if(content.width != null && content.height != null) { + content.width = aw-1; + content.height = ah-1; + } + //alert(content.width+":"+content.height); + } + if(mode == "crop") { + //alert(pic_y); + jg_doc.fillRectPattern(pic_x,pic_y,pic_width,ay-pic_y,pattern); + + var h1 = ah; + var y1 = ay; + if (ah+ay >= pic_height+pic_y) + h1 = pic_height+pic_y-ay; + else if (ay <= pic_y) + { + h1 = ay+ah-pic_y; + y1 = pic_y; + } + jg_doc.fillRectPattern(pic_x,y1,ax-pic_x,h1,pattern); + jg_doc.fillRectPattern(ax+aw,y1,pic_x+pic_width-ax-aw,h1,pattern); + jg_doc.fillRectPattern(pic_x,ay+ah,pic_width,pic_height+pic_y-ay-ah,pattern); + } + else if(mode == "scale") { + //alert("Resizing: iw:"+image.width+" nw:"+aw); + document.theImage.height = ah; + document.theImage.width = aw; + document.theImage.style.height = ah+" px"; + document.theImage.style.width = aw+" px"; + + P7_Snap('theImage','ant',0,0); + + //alert("After Resizing: iw:"+image.width+" nw:"+aw); + } + + drawBoundHandle(); + jg_doc.paint(); + + showStatus(); + return false; +} + +document.onmousedown=drags +document.onmouseup=dragStopped; + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/slider.js b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/slider.js new file mode 100755 index 0000000000..76d1b61a12 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/slider.js @@ -0,0 +1,104 @@ +/*********************************************************************** +** Title.........: Simple Lite Slider for Image Editor +** Version.......: 1.0 +** Author........: Xiang Wei ZHUO +** Filename......: slider.php +** Last changed..: 31 Aug 2003 +** Notes.........: Works in IE and Mozilla +**/ + +var ie=document.all +var ns6=document.getElementById&&!document.all + +document.onmouseup = captureStop; + +var currentSlider = null,sliderField = null; +var rangeMin = null, rangeMax= null, sx = -1, sy = -1, initX=0; + +function getMouseXY(e) { + + //alert('hello'); + x = ns6? e.clientX: event.clientX + y = ns6? e.clientY: event.clientY + + if (sx < 0) sx = x; if (sy < 0) sy = y; + + var dx = initX +(x-sx); + + if (dx <= rangeMin) + dx = rangeMin; + else if (dx >= rangeMax) + dx = rangeMax; + + var range = (dx-rangeMin)/(rangeMax - rangeMin)*100; + + if (currentSlider != null) + currentSlider.style.left = dx; + + if (sliderField != null) + { + sliderField.value = parseInt(range); + } + return false; + +} + +function init() +{ + if (currentSlider == null) + currentSlider = MM_findObj('sliderbar'); + + if (sliderField == null) + sliderField = MM_findObj('quality'); + + if (rangeMin == null) + rangeMin = 3 + if (rangeMax == null) + { + var track = MM_findObj('slidertrack'); + rangeMax = parseInt(track.style.width); + } + +} + +function updateSlider(value) +{ + init(); + + var newValue = parseInt(value)/100*(rangeMax-rangeMin); + + if (newValue <= rangeMin) + newValue = rangeMin; + else if (newValue >= rangeMax) + newValue = rangeMax; + + if (currentSlider != null) + currentSlider.style.left = newValue; + + var range = newValue/(rangeMax - rangeMin)*100; + + if (sliderField != null) + sliderField.value = parseInt(range); +} + +function captureStart(){ + + init(); + + initX = parseInt(currentSlider.style.left); + if (initX > rangeMax) + initX = rangeMax; + else if (initX < rangeMin) + initX = rangeMin; + + document.onmousemove = getMouseXY; + + return false; +} + +function captureStop() +{ + sx = -1; sy = -1; + document.onmousemove = null; + return false; +} \ No newline at end of file diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/wz_jsgraphics.js b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/wz_jsgraphics.js new file mode 100755 index 0000000000..b5c215191e --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/jscripts/wz_jsgraphics.js @@ -0,0 +1,921 @@ +/*********************************************************************** +** Title.........: Javascript Graphics +** Version.......: 1.0 +** Author........: Xiang Wei ZHUO +** Filename......: wz_jsgraphics.js +** Last changed..: 31 Aug 2003 +** Notes.........: Modified for Image Editor, added extra commands +**/ + +/* This notice must be untouched at all times. + +wz_jsgraphics.js v. 2.03 +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Copyright (c) 2002-2003 Walter Zorn. All rights reserved. +Created 3. 11. 2002 by Walter Zorn +Last modified: 11. 6. 2003 + +High Performance JavaScript Graphics Library. +Provides methods +- to draw lines, rectangles, ellipses, polygons + with specifiable line thickness, +- to fill rectangles and ellipses +- to draw text. +NOTE: Operations, functions and branching have rather been optimized +to efficiency and speed than to shortness of source code. + +This program is free software; +you can redistribute it and/or modify it under the terms of the +GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License +at http://www.gnu.org/copyleft/gpl.html for more details. +*/ + + + + + +var jg_ihtm, jg_ie, jg_dom, +jg_n4 = (document.layers && typeof document.classes != "undefined"); + + + + + +function chkDHTM(x, i) +{ + x = document.body || null; + jg_ie = (x && typeof x.insertAdjacentHTML != "undefined"); + jg_dom = (x && !jg_ie && + typeof x.appendChild != "undefined" && + typeof document.createRange != "undefined" && + typeof (i = document.createRange()).setStartBefore != "undefined" && + typeof i.createContextualFragment != "undefined"); + jg_ihtm = (!jg_ie && !jg_dom && x && typeof x.innerHTML != "undefined"); +} + + + + + +function pntDoc() +{ + this.wnd.document.write(this.htm); + this.htm = ''; +} + + + + + +function pntCnvDom() +{ + var x = document.createRange(); + x.setStartBefore(this.cnv); + x = x.createContextualFragment(this.htm); + this.cnv.appendChild(x); + this.htm = ''; +} + + + + + +function pntCnvIe() +{ + this.cnv.insertAdjacentHTML("BeforeEnd", this.htm); + this.htm = ''; +} + + + + + +function pntCnvIhtm() +{ + this.cnv.innerHTML += this.htm; + this.htm = ''; +} + + + + + +function pntCnv() +{ + this.htm = ''; +} + + + + + +function mkDiv(x, y, w, h) +{ + this.htm += '
<\/div>'; + + //alert(this.htm); +} + + + + +function mkDivPrint(x, y, w, h) +{ + this.htm += '
<\/div>'; +} + + + + + +function mkLyr(x, y, w, h) +{ + this.htm += '<\/layer>\n'; +} + + + + + +function mkLbl(txt, x, y) +{ + this.htm += '
'+ + txt + + '<\/div>'; +} + + + + + +function mkLin(x1, y1, x2, y2) +{ + if (x1 > x2) + { + var _x2 = x2; + var _y2 = y2; + x2 = x1; + y2 = y1; + x1 = _x2; + y1 = _y2; + } + var dx = x2-x1, dy = Math.abs(y2-y1), + x = x1, y = y1, + yIncr = (y1 > y2)? -1 : 1; + + if (dx >= dy) + { + var pr = dy<<1, + pru = pr - (dx<<1), + p = pr-dx, + ox = x; + while ((dx--) > 0) + { + ++x; + if (p > 0) + { + this.mkDiv(ox, y, x-ox, 1); + y += yIncr; + p += pru; + ox = x; + } + else p += pr; + } + this.mkDiv(ox, y, x2-ox+1, 1); + } + + else + { + var pr = dx<<1, + pru = pr - (dy<<1), + p = pr-dy, + oy = y; + if (y2 <= y1) + { + while ((dy--) > 0) + { + if (p > 0) + { + this.mkDiv(x++, y, 1, oy-y+1); + y += yIncr; + p += pru; + oy = y; + } + else + { + y += yIncr; + p += pr; + } + } + this.mkDiv(x2, y2, 1, oy-y2+1); + } + else + { + while ((dy--) > 0) + { + y += yIncr; + if (p > 0) + { + this.mkDiv(x++, oy, 1, y-oy); + p += pru; + oy = y; + } + else p += pr; + } + this.mkDiv(x2, oy, 1, y2-oy+1); + } + } +} + + + + + +function mkLin2D(x1, y1, x2, y2) +{ + if (x1 > x2) + { + var _x2 = x2; + var _y2 = y2; + x2 = x1; + y2 = y1; + x1 = _x2; + y1 = _y2; + } + var dx = x2-x1, dy = Math.abs(y2-y1), + x = x1, y = y1, + yIncr = (y1 > y2)? -1 : 1; + + + var s = this.stroke; + if (dx >= dy) + { + if (s-0x3 > 0) + { + var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx; + _s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1; + } + else var _s = s; + var ad = Math.ceil(s/2); + + var pr = dy<<1, + pru = pr - (dx<<1), + p = pr-dx, + ox = x; + while ((dx--) > 0) + { + ++x; + if (p > 0) + { + this.mkDiv(ox, y, x-ox+ad, _s); + y += yIncr; + p += pru; + ox = x; + } + else p += pr; + } + this.mkDiv(ox, y, x2-ox+ad+1, _s); + } + + else + { + if (s-0x3 > 0) + { + var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy; + _s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1; + } + else var _s = s; + var ad = Math.round(s/2); + + var pr = dx<<1, + pru = pr - (dy<<1), + p = pr-dy, + oy = y; + if (y2 <= y1) + { + ++ad; + while ((dy--) > 0) + { + if (p > 0) + { + this.mkDiv(x++, y, _s, oy-y+ad); + y += yIncr; + p += pru; + oy = y; + } + else + { + y += yIncr; + p += pr; + } + } + this.mkDiv(x2, y2, _s, oy-y2+ad); + } + else + { + while ((dy--) > 0) + { + y += yIncr; + if (p > 0) + { + this.mkDiv(x++, oy, _s, y-oy+ad); + p += pru; + oy = y; + } + else p += pr; + } + this.mkDiv(x2, oy, _s, y2-oy+ad+1); + } + } +} + + + + + +function mkLinDott(x1, y1, x2, y2) +{ + if (x1 > x2) + { + var _x2 = x2; + var _y2 = y2; + x2 = x1; + y2 = y1; + x1 = _x2; + y1 = _y2; + } + var dx = x2-x1, dy = Math.abs(y2-y1), + x = x1, y = y1, + yIncr = (y1 > y2)? -1 : 1, + drw = true; + if (dx >= dy) + { + var pr = dy<<1, + pru = pr - (dx<<1), + p = pr-dx; + while ((dx--) > 0) + { + if (drw) this.mkDiv(x, y, 1, 1); + drw = !drw; + if (p > 0) + { + y += yIncr; + p += pru; + } + else p += pr; + ++x; + } + if (drw) this.mkDiv(x, y, 1, 1); + } + + else + { + var pr = dx<<1, + pru = pr - (dy<<1), + p = pr-dy; + while ((dy--) > 0) + { + if (drw) this.mkDiv(x, y, 1, 1); + drw = !drw; + y += yIncr; + if (p > 0) + { + ++x; + p += pru; + } + else p += pr; + } + if (drw) this.mkDiv(x, y, 1, 1); + } +} + + + + + +function mkOv(left, top, width, height) +{ + var a = width>>1, b = height>>1, + wod = width&1, hod = (height&1)+1, + cx = left+a, cy = top+b, + x = 0, y = b, + ox = 0, oy = b, + aa = (a*a)<<1, bb = (b*b)<<1, + st = (aa>>1)*(1-(b<<1)) + bb, + tt = (bb>>1) - aa*((b<<1)-1), + w, h; + while (y > 0) + { + if (st < 0) + { + st += bb*((x<<1)+0x3); + tt += (bb<<1)*(++x); + } + else if (tt < 0) + { + st += bb*((x<<1)+0x3) - (aa<<1)*(y-1); + tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3); + w = x-ox; + h = oy-y; + if (w&0x2 && h&0x2) + { + this.mkOvQds(cx, cy, -x+0x2, ox+wod, -oy, oy-1+hod, 1, 1); + this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1); + } + else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h); + ox = x; + oy = y; + } + else + { + tt -= aa*((y<<1)-0x3); + st -= (aa<<1)*(--y); + } + } + this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod); + this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod); +} + + + + + +function mkOv2D(left, top, width, height) +{ + var s = this.stroke; + width += s-1; + height += s-1; + var a = width>>1, b = height>>1, + wod = width&1, hod = (height&1)+1, + cx = left+a, cy = top+b, + x = 0, y = b, + aa = (a*a)<<1, bb = (b*b)<<1, + st = (aa>>1)*(1-(b<<1)) + bb, + tt = (bb>>1) - aa*((b<<1)-1); + + + if (s-0x4 < 0 && (!(s-0x2) || width-0x33 > 0 && height-0x33 > 0)) + { + var ox = 0, oy = b, + w, h, + pxl, pxr, pxt, pxb, pxw; + while (y > 0) + { + if (st < 0) + { + st += bb*((x<<1)+0x3); + tt += (bb<<1)*(++x); + } + else if (tt < 0) + { + st += bb*((x<<1)+0x3) - (aa<<1)*(y-1); + tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3); + w = x-ox; + h = oy-y; + + if (w-1) + { + pxw = w+1+(s&1); + h = s; + } + else if (h-1) + { + pxw = s; + h += 1+(s&1); + } + else pxw = h = s; + this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h); + ox = x; + oy = y; + } + else + { + tt -= aa*((y<<1)-0x3); + st -= (aa<<1)*(--y); + } + } + this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod); + this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod); + } + + + else + { + var _a = (width-((s-1)<<1))>>1, + _b = (height-((s-1)<<1))>>1, + _x = 0, _y = _b, + _aa = (_a*_a)<<1, _bb = (_b*_b)<<1, + _st = (_aa>>1)*(1-(_b<<1)) + _bb, + _tt = (_bb>>1) - _aa*((_b<<1)-1), + + pxl = new Array(), + pxt = new Array(), + _pxb = new Array(); + pxl[0] = 0; + pxt[0] = b; + _pxb[0] = _b-1; + while (y > 0) + { + if (st < 0) + { + st += bb*((x<<1)+0x3); + tt += (bb<<1)*(++x); + pxl[pxl.length] = x; + pxt[pxt.length] = y; + } + else if (tt < 0) + { + st += bb*((x<<1)+0x3) - (aa<<1)*(y-1); + tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3); + pxl[pxl.length] = x; + pxt[pxt.length] = y; + } + else + { + tt -= aa*((y<<1)-0x3); + st -= (aa<<1)*(--y); + } + + if (_y > 0) + { + if (_st < 0) + { + _st += _bb*((_x<<1)+0x3); + _tt += (_bb<<1)*(++_x); + _pxb[_pxb.length] = _y-1; + } + else if (_tt < 0) + { + _st += _bb*((_x<<1)+0x3) - (_aa<<1)*(_y-1); + _tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-0x3); + _pxb[_pxb.length] = _y-1; + } + else + { + _tt -= _aa*((_y<<1)-0x3); + _st -= (_aa<<1)*(--_y); + _pxb[_pxb.length-1]--; + } + } + } + + var ox = 0, oy = b, + _oy = _pxb[0], + l = pxl.length, + w, h; + for (var i = 0; i < l; i++) + { + if (typeof _pxb[i] != "undefined") + { + if (_pxb[i] < _oy || pxt[i] < oy) + { + x = pxl[i]; + this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy); + ox = x; + oy = pxt[i]; + _oy = _pxb[i]; + } + } + else + { + x = pxl[i]; + this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod); + this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); + ox = x; + oy = pxt[i]; + } + } + this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod); + this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); + } +} + + + + + +function mkOvDott(left, top, width, height) +{ + var a = width>>1, b = height>>1, + wod = width&1, hod = height&1, + cx = left+a, cy = top+b, + x = 0, y = b, + aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1, + st = (aa2>>1)*(1-(b<<1)) + bb, + tt = (bb>>1) - aa2*((b<<1)-1), + drw = true; + while (y > 0) + { + if (st < 0) + { + st += bb*((x<<1)+0x3); + tt += (bb<<1)*(++x); + } + else if (tt < 0) + { + st += bb*((x<<1)+0x3) - aa4*(y-1); + tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3); + } + else + { + tt -= aa2*((y<<1)-0x3); + st -= aa4*(--y); + } + if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1); + drw = !drw; + } +} + + + + + +function mkRect(x, y, w, h) +{ + var s = this.stroke; + this.mkDiv(x, y, w, s); + this.mkDiv(x+w, y, s, h); + this.mkDiv(x, y+h, w+s, s); + this.mkDiv(x, y+s, s, h-s); +} + + + + + +function mkRectDott(x, y, w, h) +{ + this.drawLine(x, y, x+w, y); + this.drawLine(x+w, y, x+w, y+h); + this.drawLine(x, y+h, x+w, y+h); + this.drawLine(x, y, x, y+h); +} + + + + + +function jsgFont() +{ + this.PLAIN = 'font-weight:normal;'; + this.BOLD = 'font-weight:bold;'; + this.ITALIC = 'font-style:italic;'; + this.ITALIC_BOLD = this.ITALIC + this.BOLD; + this.BOLD_ITALIC = this.ITALIC_BOLD; +} +var Font = new jsgFont(); + + + + + +function jsgStroke() +{ + this.DOTTED = -1; +} +var Stroke = new jsgStroke(); + + + + + +function jsGraphics(id, wnd) +{ + this.setColor = new Function('arg', 'this.color = arg;'); + + + this.getColor = new Function('return this.color'); + + this.setStroke = function(x) + { + this.stroke = x; + if (!(x+1)) + { + this.drawLine = mkLinDott; + this.mkOv = mkOvDott; + this.drawRect = mkRectDott; + } + else if (x-1 > 0) + { + this.drawLine = mkLin2D; + this.mkOv = mkOv2D; + this.drawRect = mkRect; + } + else + { + this.drawLine = mkLin; + this.mkOv = mkOv; + this.drawRect = mkRect; + } + }; + + + + this.setPrintable = function(arg) + { + this.printable = arg; + this.mkDiv = jg_n4? mkLyr : arg? mkDivPrint : mkDiv; + }; + + + + this.setFont = function(fam, sz, sty) + { + this.ftFam = fam; + this.ftSz = sz; + this.ftSty = sty || Font.PLAIN; + }; + + + + this.drawPolyline = this.drawPolyLine = function(x, y, s) + { + var i = x.length-1; while (i >= 0) + this.drawLine(x[i], y[i], x[--i], y[i]); + }; + + + + this.fillRect = function(x, y, w, h) + { + this.mkDiv(x, y, w, h); + }; + + + this.fillRectPattern = function(x, y, w, h, url) + { + this.htm += '
<\/div>'; + //alert(this.htm); + } + + this.drawHandle = function(x, y, w, h, cursor) + { + + this.htm += '
<\/div>'; + } + + this.drawHandleBox = function(x, y, w, h, cursor) + { + + this.htm += '
<\/div>'; + + + } + + this.drawPolygon = function(x, y) + { + this.drawPolyline(x, y); + this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]); + }; + + + + this.drawEllipse = this.drawOval = function(x, y, w, h) + { + this.mkOv(x, y, w, h); + }; + + + + this.fillEllipse = this.fillOval = function(left, top, w, h) + { + var a = (w -= 1)>>1, b = (h -= 1)>>1, + wod = (w&1)+1, hod = (h&1)+1, + cx = left+a, cy = top+b, + x = 0, y = b, + ox = 0, oy = b, + aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1, + st = (aa2>>1)*(1-(b<<1)) + bb, + tt = (bb>>1) - aa2*((b<<1)-1), + pxl, dw, dh; + if (w+1) while (y > 0) + { + if (st < 0) + { + st += bb*((x<<1)+0x3); + tt += (bb<<1)*(++x); + } + else if (tt < 0) + { + st += bb*((x<<1)+0x3) - aa4*(y-1); + pxl = cx-x; + dw = (x<<1)+wod; + tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3); + dh = oy-y; + this.mkDiv(pxl, cy-oy, dw, dh); + this.mkDiv(pxl, cy+oy-dh+hod, dw, dh); + ox = x; + oy = y; + } + else + { + tt -= aa2*((y<<1)-0x3); + st -= aa4*(--y); + } + } + this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod); + }; + + + + this.drawString = mkLbl; + + + + this.clear = function() + { + this.htm = ""; + if (this.cnv) this.cnv.innerHTML = this.defhtm; + + }; + + + + this.mkOvQds = function(cx, cy, xl, xr, yt, yb, w, h) + { + this.mkDiv(xr+cx, yt+cy, w, h); + this.mkDiv(xr+cx, yb+cy, w, h); + this.mkDiv(xl+cx, yb+cy, w, h); + this.mkDiv(xl+cx, yt+cy, w, h); + }; + + + this.setStroke(1); + this.setPrintable(false); + this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN); + this.color = '#000000'; + this.htm = ''; + this.wnd = wnd || window; + + + if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM(); + if (typeof id != 'string' || !id) this.paint = pntDoc; + else + { + this.cnv = document.all? (this.wnd.document.all[id] || null) + : document.getElementById? (this.wnd.document.getElementById(id) || null) + : null; + this.defhtm = (this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : ''; + this.paint = jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv; + } +} diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/load_image.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/load_image.php new file mode 100755 index 0000000000..f39f97681d --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/load_image.php @@ -0,0 +1,138 @@ + +** Filename......: load_image.php +** Last changed..: 30 Aug 2003 +** Notes.........: Configuration in config.inc.php + + Uses the GD, ImageMagic or NetPBM to manipulate + images online. ImageMagic is preferred as it provides + the best rotation algorithm. Below is a brief comparsion + of the image manipulation packages. Personal preference + is ImageMagick. + + | GD | NetPBM | ImageMagick + ------------------------------------------------ + GIF NO(1) YES YES + JPEG YES(2) YES YES + PNG YES YES YES + Cropping Good Good Good + Scaling Fair Good Very Good + Rotation Poor Fair Very Good + Flip Good Poor Good + + + (1) GIF is support in old GD say version 1.61 and below + (2) Full colour JPEG is not supported in GD versions + less than 2.01 with PHP. + +***********************************************************************/ + +//*************************************************************************** + +include '../ImageManager/config.inc.php'; + +// set this to whatever subdir you make +$path = $BASE_ROOT.'/'; + +//*************************************************************************** + +//echo $path; + +require_once 'Transform.php'; + +$action = ''; + +//get the image file +$img_file = $_GET['img']; + +if($img_file != '') { + $path_info = pathinfo(urldecode($img_file)); + $path = $path_info['dirname']."/"; + $img_file = $path_info['basename']; +} +//var_dump($path); +//var_dump($path_info); + +//get the parameters +if (isset($_GET['action'])) + $action = $_GET['action']; +if (isset($_GET['params'])) + $params = $_GET['params']; +if(isset($_GET['file'])) { + $save_file = urldecode($_GET['file']); +} + +//manipulate the image if the parameters are valid +if(isset($params)) { + $values = explode(',',$params,4); + if(count($values)>0) { + $file = manipulate($img_file, $action, $values); + } +} + +//manipulate the images +function manipulate($img_file, $action, $values) +{ + global $path, $save_file, $BASE_DIR; + + //Load the Image Manipulation Driver + $img = Image_Transform::factory(IMAGE_CLASS); + $img->load($BASE_DIR.$path.$img_file); +//var_dump($_SERVER['DOCUMENT_ROOT'].$path.$img_file); + switch ($action) { + case 'crop': + $img->crop(intval($values[0]),intval($values[1]),intval($values[2]),intval($values[3])); + break; + case 'scale': + $img->resize(intval($values[0]),intval($values[1])); + break; + case 'rotate': + $img->rotate(floatval($values[0])); + break; + case 'flip': + if ($values[0] == 'hoz') + $img->flip(true); + else if($values[0] == 'ver') + $img->flip(false); + break; + case 'save': + + if (isset($save_file)) + { + $quality = intval($values[1]); + if($quality <0) + $quality = 85; + $img->save($BASE_DIR.$path.$save_file, $values[0], $quality); + } + break; + } + + //get the unique file name + $filename = $img->createUnique($BASE_DIR.$path); + //save the manipulated image + $img->save($BASE_DIR.$path.$filename); + $img->free(); + + $imagesize = @getimagesize($filename); + return array($filename, $imagesize[3]); +} + + +//well, let say the image was not manipulated, or no action parameter was given +//we will get the image dimension anyway. +$image = $img_file; +$size = @getimagesize($image); +$dimensions = $size[3]; + +if (isset($file) && is_array($file)) +{ + $image = $file[0]; + $dimensions = $file[1]; +} + +//now display the image with +include 'man_image.html'; +?> \ No newline at end of file diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/locked.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/locked.gif new file mode 100755 index 0000000000000000000000000000000000000000..1dfd2ec73f9454422198e59bc23e8934ebfa1cc1 GIT binary patch literal 321 zcmZ?wbhEHbEz^SWo2n>Y^KMo}b_B0yuwc%S + + + + + + + + + +
+ + + + + +
+ BORDER=0 ALT="" id="theImage" name="theImage"> +
+ + + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/rotate.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/rotate.gif new file mode 100755 index 0000000000000000000000000000000000000000..f1ece0bb3b58d7e941635925ea178c4fdb371ee1 GIT binary patch literal 95 zcmZ?wbhEHb6k!lyn8?78mNxVM|Nl2{-eh24Q2fclD#F0XpaWzBWknbmm<)RQSDt>$ zFU_&QFQfU!)kp<}Lq~I>ncTcqC@taM*tuuV+AwcE+v*ikN+0D8&)yiwz+epkrqCdV literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ruler.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ruler.gif new file mode 100755 index 0000000000000000000000000000000000000000..4bac2b5a281467f616c5d5bf3ff4ddaf78783064 GIT binary patch literal 99 zcmZ?wbhEHb6k!lyn8?78mNxVM|Nl2{-eh24Q2fclD#F0XpaWzBWknbmm`r;5SDrrm zAg)31VkGaL?H?~|Ml*3VEoodPGVQrgmUd6%W{y?*_wH@k`}u{Dgm|Esidz3vCI)K& DdpRSq literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/save.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/save.gif new file mode 100755 index 0000000000000000000000000000000000000000..be88461699882f7862f53ccf4ab9c58347672c72 GIT binary patch literal 112 zcmZ?wbhEHb6k!lyn8?78mNxU-w{JIZ-u(anzv538RuKkf1|0?<0Le2jInL={dHOBS zqB+5hh1Xe?ayv>-EN_)#D@sqBsT{RR-_5nHW&>~C{jF!4uT~vABM|x}bi$&G{g-T5 QSgx$v`s+lNC@X_C0Ds*sT>t<8 literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/scale.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/scale.gif new file mode 100755 index 0000000000000000000000000000000000000000..2d0adb6802565917b0dd4ef0ff1df1a9bf0c40c7 GIT binary patch literal 114 zcmV-&0FD1gNk%w1VH5xq0FeLyW@efH|Nq(9*#H0lA^8La6aWDLEC2ui02BZe0006* zjE||y?GB=xash#}7FYH5A)zq^BPk>jcADt{xM>^4>HEbxX9h3)yLE0J9E^et1vgBi U=iyuYEInQCLCiw8Tt@)_JC&^|t^fc4 literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/spacer.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/spacer.gif new file mode 100755 index 0000000000000000000000000000000000000000..fc2560981ee1caca400e225e48d282106f907f2d GIT binary patch literal 43 ucmZ?wbhEHbWMp7uXkcLY|NlP&1B2pE7Df>utpmhBaYhCPCMFj~25SJyItL8^ literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/t_black.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/t_black.gif new file mode 100755 index 0000000000000000000000000000000000000000..0eb0b17a198fef6136a93aa2640e4b2d13c8423a GIT binary patch literal 99 zcmZ?wbhEHb6k!lyn8*ME&z}7U0w6>2Ckv|x10#bDNE9T`z+}?Xzw$H}zjDT=OH%rE wRo~~zK2V-=NTu&tXU~ByDZM+Z(%!7Gnz!ed?@vZaJH_>ESsK&NFfmvI0Q~bJ2Ckv|x10#bDNE9T`z+}?Xzw$H}zjDT=OH%rE vRo~~zPIZ{}RK@FAm(=4bC4HSO2YGIDI!xYmXLVqcz2L{>OpWQMnHa1A(;Ok! literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/test.html b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/test.html new file mode 100755 index 0000000000..d3fbbdcc13 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/test.html @@ -0,0 +1,332 @@ + + + New Document + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +

+ Crop

+ Resize

+ Rotate

+ Measure

+ Marker

+ Save
+
+ +
+ + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnBack.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnBack.gif new file mode 100755 index 0000000000000000000000000000000000000000..62734b0b5cfb276628caf41d3affbfab1d6ac480 GIT binary patch literal 603 zcmZ?wbhEHb1ERneK_UgpT*=m)FB}c8dKAbMJo;6~h%HuCL7Tjub+2r81P1a+# zZ17>*{m<6O^m1qK)imieSp8rYM=G<%R3)X&Jk~oT`YxplPiM0}ZdHHEbH?te(fifb z+@F-RUvJr+o~c)hi;p^8d2-R|s1x5h=C*UuTv^OPdzFsfKf3L~HoNt9A`Kjk*DFLa z1;jV7FS*sQ@5R=hYsJ8Dq7hL1$-*kaz{H>fG9MHt4D34^n3|Xjg`SD$e}>|N5zoS??a4zq%@R>-L>zW*Xl*z5f5(dH-Kd z`u}bFm+J)$#c?k$b^iac;?vhZuWxQYcj4N{r#DJ6ga7}(dtjo{!z+8vZSwzkDE|Nd z_x~R@_jkA4-ckJj`@CyggAVj+o||v|>)VT8KVJX;zw!Ewo1dPZ{JJmd_RiR6_m2L5 z(fj{L@5ROLACHy(|G)VE|1)Jd;s5`y`TuMGsl`?|Hs^eJdg0Ta$Zv0Me|o(1=FW&8 zKmUGtdGr7Oncu&Ee{%a21MPw0PZm}Y27d+}kX4{KVPN0c;NR4w)Y{4-B4TRV?BCWQ zGJ&PXKSDJm#50P;YR&|IAwH|chH?B(D;A6R`ndc_A7J$p<=x9hKM^jZzt#)D4WbFgPq;?5@EeFr#3L XV_V~7_0$zp0+)C%o^HU*$Y2cs8p;k^ literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnFolderUp.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/btnFolderUp.gif new file mode 100755 index 0000000000000000000000000000000000000000..7bd245dbc268cc2d716731da3693fdb1e16ea4ea GIT binary patch literal 599 zcmV-d0;v5*Nk%w1VGjTg0OkMy0A>K|!$;Ad43>`t?&s0p#Be)`I_ub-e6V^YkQ;j5 zNAu&4-?vO`(L^(50KnL%SfoSw_PFrcg-N_5%H7CZ$1XLR93*)u@5W?;=1}hR!@R#& zGk_WY?u**1Bd5ot{`Sxpdlc^9t*69W>0PWe7Mtui7qaN?nPfMIU6m=6Xg)Jd> z1pn)V`Q>qu_g&1)X8-q#-LEzG|HIw8RsZsv|JaJv;?g9C8urp;|Np`N?62t8sQ=b- z|NrSZw;n}=DkG>8D2*8Z|IGgNwtwSIZqqvndj$Xgnd{F>f;0?s zDh@a}IbT>85IcfIHC07VEoWv}3I>EkOeQ8(Fbh5kS9vHBw?{`nI$K^+84YAN47Yk| z5?wbSJwa~|P$#!Y3=vgmFH~h5RwQt@7$PP^Ln8@FLOK)}L_`dTA3r+qptB*&9RdW` lG&!>*zyKR@jI4k`@PG#aDeBmf6T#iE8BPeGkyIrR06SHi9en@* literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php new file mode 100755 index 0000000000..c92db33e8a --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php @@ -0,0 +1,55 @@ + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/dots.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/dots.gif new file mode 100755 index 0000000000000000000000000000000000000000..859294e770948d1c131d2d5d5dd43c79bdcd864a GIT binary patch literal 181 zcmZ?wbhEHb6l36FSj52a|NsB3=brU!y_Pof43NzL1B(B-{aizWogD*Qjr0td8G+)8 zKUr8M8CV!}Kx#nR8JHzGcHQ}BaLRM_UW?bh&IwHic$l9wK5{DZV?wBAVc=xoV_*WR j=C*M55$xqy_^8{M5hTxvZkh*@X{`x|53n%8OtS_69B4E` literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_active.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_active.gif new file mode 100755 index 0000000000000000000000000000000000000000..35ecf148d38a2c39ed773d0f5b4bb10bfee66af1 GIT binary patch literal 156 zcmZ?wbhEHb|R)QcD zf3mQOFt9P`fP_G1FtB)DIN`Z^uZ4FDo5B%;0^#&B7KV<+rBzwGJ5MsI#O9QEE?U(t u(DmH#PnP0AKNXJybM}cQbqZWqA{Xf%xI&4GQE=sw87zBdl~^$`SOWltH!?v0 literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_pencil.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/edit_pencil.gif new file mode 100755 index 0000000000000000000000000000000000000000..abb9fe4cbf7ae383cb2b4218438b97cf20c374e2 GIT binary patch literal 138 zcmZ?wbhEHb;y%~9u-B3O!MGaNG5!Z5?vTf}9m3j>2S0IkT5RGmX<`{{R2q-{1f8<;!c=u08YS|HqFXf%0fT z@h1zb2m=d)4oDni1_O)TgcF{t_wLB>>61VBK=P`f0%s9hj-#xD&gpm3ZHE-D=o>01 j2;>)iV9a;+{3y<&VtwpcaivHU->jTzhu``sF<1itOieM< literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/folder.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/folder.gif new file mode 100755 index 0000000000000000000000000000000000000000..180ea1cc66adc02fa6ae8b99ef428f63cb1acbe1 GIT binary patch literal 1293 zcmV+o1@ihwNk%w1VNd{20OkMyfNeDY?1t>wVR3PB*{UD^^|RL2)@EZ_yu7^k_xH@1 z0N=k;^4FE`@9&wJnd!x7_3WSD-{083a{2P#s)Q1FY(?qPjrr}*^5%5Wt2zJ7X6)a& z(5EZ^{-cR`N&oea^3{Ubvq6M}g#Y*FudlD_-M9blzTCWBvWN};>5|Qz4*%3||NqSY z=7FJ+VwQO%*|9qR|GxkDlF_nLY-Uo-%*_AsuJ6E0|KNN7+I7~fG5_@5;>?Nv|K_8k zqw?jv=H}+Zlm-9(_xb33_1~!G%y9D0UE|ZE|L=+a|C#2uIedJ4|Nq7R|J3QvRN1pD z-nCNl-JXqeCyb1YwY9bX|E#jCnE&$E#Kgq^*K*RK5C8h_-q^*Sg*m&GBhsZG_2|Uh zwnzW}?(*i3;>AR8XG+hV2&so1|L3Ov_|4Y2WahtG=FEP!pIzdzFxjgq@5of#!*>7w z-ezWI^4)Cz|F!?)eu{H3^5(AQ$4LM1#?!4k-o<$T@}B?y{{R30A^8La6aanzEC2ui z08ju>000O7fPR95goTEOh>41ejE#!-3fYHbj015hF*14s;06;+{4=+;e) zTelkjx~Zt}HSE~3`p9fs==PhOzkvV76{27c7Nn&zT|Ne9{*Zq5u>~J@8G>_kW)m;6o{%qFaWWQd!6_2A^T2rx9!!Gsi6XyJtxYQTaDG$4RjDRHdv z01Rp1WnxnrFj1H_tAw~l7$u%4V?G){;8|{}9I?h4MWpfAk3a_bmrJ>{vwq z0YWy}qy|O25FINezyQONq-Ck)mRxeFffG{bN97xDuwg@&Xr@V;22TLs1A|DC8HEi< z)M@9Pc;<;Gn+n32N&<4G5Wt{>7Ha6BhH9X|0UoyUh8a<$(88pYR%+>`mMS_&4X(gL zgrt~;DryTipzv9z3h0r79jvzM>Z`E6dV`U!sE{fSxaO+suDs@I1ZrlyFvXFfDPTel z$R?}ovdhAugla*&a7P&fEa*xGDjdt~wmE2UgBxEcfWiv^&@jgm4v>Ha5JFt5g9%y0 zEAPBn7@@=)S|~t)6crpWfCvsyfrSA;H1J_68R&q<3Jf>Ag0lpe5d;O(&hf8m4+zu{ zLBR*JqK3i@d+SEN?e*7Shb{KlWS4FB*=VPYb|3&d DSVx&v literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php new file mode 100755 index 0000000000..59fb1e3188 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php @@ -0,0 +1,658 @@ + +** Filename......: images.php +** Last changed..: 8 Mar 2003 +** Notes.........: Configuration in config.inc.php + + Functions + - create a new folder, + - delete folder, + - upload new image + - use cached thumbnail views + +***********************************************************************/ + +include 'config.inc.php'; + +if(isset($_GET['dir'])) { + $dirParam = $_GET['dir']; + + if(strlen($dirParam) > 0) + { + if(substr($dirParam,0,1)=='/') + $IMG_ROOT .= $dirParam; + else + $IMG_ROOT = $dirParam; + } +} + +$refresh_dirs = false; +$clearUploads = false; + +if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) + $IMG_ROOT .= '/'; + + +if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false) +{ + create_folder(); +} + +if(isset($_GET['delFile']) && isset($_GET['dir'])) +{ + delete_file($_GET['delFile']); +} + +if(isset($_GET['delFolder']) && isset($_GET['dir'])) +{ + delete_folder($_GET['delFolder']); +} + +if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath'])) +{ + + $dirPathPost = $_POST['dirPath']; + + if(strlen($dirPathPost) > 0) + { + if(substr($dirPathPost,0,1)=='/') + $IMG_ROOT .= $dirPathPost; + else + $IMG_ROOT = $dirPathPost; + } + + if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) + $IMG_ROOT .= '/'; + + do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/'); +} + +function do_upload($file, $dest_dir) +{ + global $clearUploads; + + if(is_file($file['tmp_name'])) + { + //var_dump($file); echo "DIR:$dest_dir"; + move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']); + chmod($dest_dir.$file['name'], 0666); + } + + + + $clearUploads = true; +} + +function delete_folder($folder) +{ + global $BASE_DIR, $refresh_dirs; + //var_dump($BASE_DIR); + $del_folder = dir_name($BASE_DIR).$folder; + //echo $del_folder; + if(is_dir($del_folder) && num_files($del_folder) <= 0) { + //echo $del_folder.'
'; + rm_all_dir($del_folder); + $refresh_dirs = true; + } +} + +function rm_all_dir($dir) +{ + //$dir = dir_name($dir); + //echo "OPEN:".$dir.'
'; + if(is_dir($dir)) + { + $d = @dir($dir); + + while (false !== ($entry = $d->read())) + { + //echo "#".$entry.'
'; + if($entry != '.' && $entry != '..') + { + $node = $dir.'/'.$entry; + //echo "NODE:".$node; + if(is_file($node)) { + //echo " - is file
"; + unlink($node); + } + else if(is_dir($node)) { + //echo " - is Dir
"; + rm_all_dir($node); + } + } + } + $d->close(); + + rmdir($dir); + } + //echo "RM: $dir
"; +} + +function delete_file($file) +{ + global $BASE_DIR; + + $del_image = dir_name($BASE_DIR).$file; + + $del_thumb = dir_name($del_image).'.'.basename($del_image); + + if(is_file($del_image)) { + unlink($del_image); + } + + if(is_file($del_thumb)) { + unlink($del_thumb); + } +} + +function create_folder() +{ + global $BASE_DIR, $IMG_ROOT, $refresh_dirs; + + $folder_name = $_GET['foldername']; + + if(strlen($folder_name) >0) + { + $folder = $BASE_DIR.$IMG_ROOT.$folder_name; + + if(!is_dir($folder) && !is_file($folder)) + { + mkdir($folder,0777); + chmod($folder,0777); + $refresh_dirs = true; + } + } +} + +function num_files($dir) +{ + $total = 0; + + if(is_dir($dir)) + { + $d = @dir($dir); + + while (false !== ($entry = $d->read())) + { + //echo $entry."
"; + if(substr($entry,0,1) != '.') { + $total++; + } + } + $d->close(); + } + return $total; +} + +function dirs($dir,$abs_path) +{ + $d = dir($dir); + //echo "Handle: ".$d->handle."
\n"; + //echo "Path: ".$d->path."
\n"; + $dirs = array(); + while (false !== ($entry = $d->read())) { + if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') + { + //dirs($dir.'/'.$entry, $prefix.$prefix); + //echo $prefix.$entry."
\n"; + $path['path'] = $dir.'/'.$entry; + $path['name'] = $entry; + $dirs[$entry] = $path; + } + } + $d->close(); + + ksort($dirs); + for($i=0; $i= 1024 && $size < 1024*1024) + { + return sprintf('%01.2f',$size/1024.0).' Kb'; + } + else + { + return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; + } +} + +function show_image($img, $file, $info, $size) +{ + global $BASE_DIR, $BASE_URL, $newPath; + + $img_path = dir_name($img); + $img_file = basename($img); + + $thumb_image = 'thumbs.php?img='.urlencode($img); + + $img_url = $BASE_URL.$img_path.'/'.$img_file; + + $filesize = parse_size($size); + +?> + + + + + + + + +
+ <? echo $file; ?> - <? echo $filesize; ?>
+ + + + + +
+ +
+ + + + + + + + + + +
+ + <? echo $dir; ?> + +
+ + + + +
+
+ + + + + + +
No Images Found
+ + + + + +
Configuration Problem: "" does not exist.
+'; + echo ''; +} + +function draw_table_footer() +{ + echo ''; + echo ''; +} + +?> + + +Image Browser + + + 0) + { + $upDirPath .= $path.'/'; + } + } + + $slashIndex = strlen($dirPath); + $newPath = $dirPath; + if($slashIndex > 1 && substr($dirPath, $slashIndex-1, $slashIndex) == '/') + { + $newPath = substr($dirPath, 0,$slashIndex-1); + } +?> + + + + + + +'; +$d = @dir($BASE_DIR.$IMG_ROOT); + +if($d) +{ + //var_dump($d); + $images = array(); + $folders = array(); + while (false !== ($entry = $d->read())) + { + $img_file = $IMG_ROOT.$entry; + + if(is_file($BASE_DIR.$img_file) && substr($entry,0,1) != '.') + { + $image_info = @getimagesize($BASE_DIR.$img_file); + if(is_array($image_info)) + { + $file_details['file'] = $img_file; + $file_details['img_info'] = $image_info; + $file_details['size'] = filesize($BASE_DIR.$img_file); + $images[$entry] = $file_details; + //show_image($img_file, $entry, $image_info); + } + } + else if(is_dir($BASE_DIR.$img_file) && substr($entry,0,1) != '.') + { + $folders[$entry] = $img_file; + //show_dir($img_file, $entry); + } + } + $d->close(); + + if(count($images) > 0 || count($folders) > 0) + { + //now sort the folders and images by name. + ksort($images); + ksort($folders); + + draw_table_header(); + + for($i=0; $i + + + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/loading.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/loading.gif new file mode 100755 index 0000000000000000000000000000000000000000..4e0dd98d8c2f04ec9bb243a7ba9dd02ab1428fb5 GIT binary patch literal 1079 zcmZ?wbhEHb+`(YLaD;*3|NsBrzyE*#{`*G;f9~Gk*FC}wc#;SEWulE(`>~_e#U$O3e&HMic78H2s{Bk+Ar08Uh)qGQx z60fyU>&-RGPQR@xytTf!Ci!D~&5xeg{F|P4zKlS>D&Bt}`f0x$OH`O&Zx0SZG zcja|<_oepsPl}s3d0P0?>9fjmXU~hBIe(GsLIwd|KNbN_22KGMujPwp%yru2yJ`&! zCzB(ufW>w{*43LCmL4)=;^yVv%fQIa%ge)R#(MV1u00HFY>YfS%-4A?^KCHS&dJ97 z@G<9EMpKqET%Rs*UFK&$e~FhZi>2YZ0^>gC69IQ67!Eozu?rmg8#Up0=2dkR(`A*zPN9YJ0-=?!5~q!J<(y)oyp8~3yoWP(we?A#jxtU|L)kp zu)krQR>H(p4_=Dze00EsyXW&Pt6NK#UVh4W*J0Te&C3QWrZ69vD|CQagh}8k@B6z3 zzE+A08+!_*4<=o9Z5z2O6J4GF4ny=Y8 zPig6bi{gx|784$c95D$vpeK;?({oNLj|nfc|D(u$rn-NXOAUL}7&8`6aNC%%WQv?& z=F%C@K4dIgoO5dBqWNuH$CfS%dzHCz+MKRcDy!DL@>sp@kZ0DKV+XvlV~wAzdcAJX zw^y&%E4Lse{2B%s20jKRV8Z89VDVfsMP=y~lccI;*&Lv}!HJePS{JAw=Z*6vD0xGw z{{$p&Tv!3l8#mT~^2YuL8!CMCW}kntrRr?n?)x8h)cCEx{r<9V`Jl) zGiO#+RUJFLH8?nU?bFN3X`}fw?mMxo>ojG$REiLWz z$=yILj~-muv}sdyb@9sOa~?i?c<$)def##@yLR;d|NmfXsY59KWMLIyP-D;m83*zc z1KT=>h5`>0$^H{6g`6H%^G~UjNG*-(J+#_%_1vP}=k<43m8EG0rTSaVYg>R-9I}015%rs#( zCP5alWz!hh#gt}C&kK*_WEbIPQJFH0f43sH{DJvus~JVuIF9e|72s77;F0ECenORJ h?-JJT6R9bW+>@R>d-NjpRq~reALslJ@BADYtO1v4iPr!C literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/newFolder.html b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/newFolder.html new file mode 100755 index 0000000000..01469693e2 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/newFolder.html @@ -0,0 +1,89 @@ + + +New Folder + + + + + + +
New Folder
+
+ + + + + + +
+ + + + +
Folder Name:
+
+ + +
+
+

 


+ + \ No newline at end of file diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/noimages.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/noimages.gif new file mode 100755 index 0000000000000000000000000000000000000000..3014d9468f745204aada320e7ab08d9052347ac4 GIT binary patch literal 780 zcmV+n1M~bxNk%w1VYmP=0HOc@%*@RH|Nqt1)#c^o@9*#5-{1B1_5c6>A^8La6aWVR zEC2ui0Js1!000C37`oj4Fv>}*y*TU5yZ>M)j$~<`XsWJk>%MR-&vb3yc&_h!@BhG{ za7Zi~kI1BQ$!t2G(5Q4uty+Twfnd=_&=~;U1cqC{dDEYQw_bmT z5#VinasYi9b}?jVAb9`-j*oFMe*lpiZhB&Kb%ZdNg^O=Fla(5CdJCEh1O;}A4Tk}0 zbXkOvWQ2;hcBBEiyKD*tj0M07x?2&95eBSp1q`yqT9ID8&c(6K1EYak&c>VylY5^G zu%mmFmzWFb>zc#j4Ev%|)sIE4WQg3GgwQ6y~~_3*-= z$!026g_=P)_swIY1xjOO9CXlHRd}5I*+ZC7Ck007;#?{=QY22V65Bn^SrQe_QsI22 z@_KWt1E!SRUbWg_fG{l~+3K6b#giGG zHRG*xiK<>gfUk~wXV{E@IICef;MYJULN1cgR@Nz5GTc7RV1f3n_94#Fdh2Ei=?|kL z0>zL=@U^yf<(J{q;y$}py5-()Go+#j>v8f2qtAn@YTKzt&6kTAP`ocY1KOrl0SZWX z{q2>}dcjx0cve;PQB!vrh#6n!(Ke1pTf|feg38cBl0Me$g%F0eL3CMnyRGGuNFy#} zUjU5skz$Gwr03sx;{X7^q*7#xKzD@vs{pkK8j51fQ1DhHRyDC+2=kVY!$q?A@_>7|%vs_CYjcIxS;poS{y KsH9Sm0027{!FbXD literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php new file mode 100755 index 0000000000..7fd8c3ae78 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php @@ -0,0 +1,91 @@ + +** Filename......: thumbs.php +** Last changed..: 1 Mar 2003 +** Notes.........: Configuration in config.inc.php + + - if the thumbnail does not exists or the source + file is newer, create a new thumbnail. + +***********************************************************************/ + + +include 'config.inc.php'; +require_once '../ImageEditor/Transform.php'; + +$img = $BASE_DIR.urldecode($_GET['img']); + +if(is_file($img)) { + make_thumbs(urldecode($_GET['img'])); +} + + +function make_thumbs($img) +{ + global $BASE_DIR, $BASE_URL; + + + $path_info = pathinfo($img); + $path = $path_info['dirname']."/"; + $img_file = $path_info['basename']; + + $thumb = $path.'.'.$img_file; + + $img_info = getimagesize($BASE_DIR.$path.$img_file); + $w = $img_info[0]; $h = $img_info[1]; + + $nw = 96; $nh = 96; + + if($w <= $nw && $h <= $nh) { + header('Location: '.$BASE_URL.$path.$img_file); + exit(); + } + + if(is_file($BASE_DIR.$thumb)) { + + $t_mtime = filemtime($BASE_DIR.$thumb); + $o_mtime = filemtime($BASE_DIR.$img); + + if($t_mtime > $o_mtime) { + //echo $BASE_URL.$path.'.'.$img_file; + header('Location: '.$BASE_URL.$path.'.'.$img_file); + exit(); + } + } + + $img_thumbs = Image_Transform::factory(IMAGE_CLASS); + $img_thumbs->load($BASE_DIR.$path.$img_file); + + + if ($w > $h) + $nh = unpercent(percent($nw, $w), $h); + else if ($h > $w) + $nw = unpercent(percent($nh, $h), $w); + + $img_thumbs->resize($nw, $nh); + + $img_thumbs->save($BASE_DIR.$thumb); + $img_thumbs->free(); + + chmod($BASE_DIR.$thumb, 0666); + + if(is_file($BASE_DIR.$thumb)) { + //echo "Made:".$BASE_URL.$path.'.'.$img_file; + header('Location: '.$BASE_URL.$path.'.'.$img_file); + exit(); + } +} +function percent($p, $w) + { + return (real)(100 * ($p / $w)); + } + +function unpercent($percent, $whole) + { + return (real)(($percent * $whole) / 100); + } + +?> \ No newline at end of file diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/unlocked.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/unlocked.gif new file mode 100755 index 0000000000000000000000000000000000000000..fe4e0d4bbda523432c60edad8f777b42adbcd7bd GIT binary patch literal 73 zcmZ?wbhEHblw?p~n8*ME|G@yrQ2fclD#F0TpaT*G$ulrXP3d2G`Yr$BIa_XZZ@#zZ TH-FnBk7>_3m%Zu|Wv~VSI1Czy literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/uploading.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/uploading.gif new file mode 100755 index 0000000000000000000000000000000000000000..3885617e0f4d71d59b4223a0e097abe9041e8b13 GIT binary patch literal 1046 zcmZ?wbhEHb+`(YLaD;*3|NsBrzyE*#{`*G;f9~Gk*FC}wc#;SEWulE(`>~_e#U$O3e&HMic78H2s{Bk+Ar08Uh)qGQx z60fyU>&-RGPQR@xytTf!Ci!D~&5xeg{F|P4zKlS>D&Bt}`f0x$OH`O&Zx0SZG zcja|<_oepsPl}s3d0P0?>9fjmXU~hBIe(Gs!o|xRmYNIjn(?l&S?#@%MS#pn*Z~dJ_x3#DA_6t=VB~Te-}fBt8fpVrJr&kZWmJeEm>@rRb9_sSHfb z@d7+rn>sc|2QgSaJ!<8!;g}l(tHP^lPf;b^FuQt9hJY*6{O4Q8nl6wOyI~t0F!_;D z#o8owWncY$pCq{xd2?A=+E^ZhzYmM&sbzc65uCm{blr`8J>O0@uAb7{t7fph6C>Z63N>uV=}+wnXlVL#u8N1_T2ez9}-4c}&%Dt}xgki78O zoMP3FO!~90vs6o)U0-g^bv?s-!HfNjUfCQDyw}~fHqY0e=9XNzWb++AVG)nab5EHV zzDL}A)7!lwkZDK2_gjh4whZU(x86N)_iz#)%LI7_<%?HD`JQi`6sMOJq0-)deJuw6C|lY4em?6?x^$>VUK zck`VJX9kuFDa{NlE$01`9Zei$`nT{NRGE6)^=F6ch9&N7S==8E9hiEEhw&NT!!?Br zy}U9Csk0o{cs|!GyJzV&ud41)`uy2{IA5qX@mYB;Y^(E3S=7U~Ib(5~64y$_Nq$-$ zOQ#8a%2-x@?!n9D3)-|^tynTmfC-VVYZzo0_!yXg>6%Z0#dFCNm8DlqlB$+vbAXg^ zq9y&-1uDo%|9lBb(wFK#0ZIB7R)CZKjWwX8zyHC83Lm}M=U;58I-9rq{)Zhke(P_) z|FNg;{QKYk8ycIMTUy)9d3jX?1XMUV+mk!HdzJeq&X_rC_MEx%<}X;dXz`Mz%a*TL TxoY*Awd>Yz*tjW0k--`O&R4}A literal 0 HcmV?d00001