add new UploadImage plugin by Pim Snel ;)

This commit is contained in:
Pim Snel 2004-04-21 20:43:23 +00:00
parent 60ec7792c9
commit 7b24abc7b9
44 changed files with 5187 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View File

@ -0,0 +1,490 @@
<?php
/***********************************************************************
** Title.........: GD Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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 <peter@mapledesign.co.uk> |
// | Alan Knowles <alan@akbkhome.com> |
// +----------------------------------------------------------------------+
//
// 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<br>";
$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
?>

View File

@ -0,0 +1,231 @@
<?php
/***********************************************************************
** Title.........: ImageMagick Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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 <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
// $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
?>

View File

@ -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; }

View File

@ -0,0 +1,354 @@
<?
/***********************************************************************
** Title.........: Online Image Editor
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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));
}
?>
<html style="width:700px; height:550;">
<HEAD>
<TITLE> Editing: <? echo $path_info['basename']; ?></TITLE>
<script type="text/javascript" src="../popup.js"></script>
<script type="text/javascript" src="../../dialog.js"></script>
<link href="ImageEditor.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function pviiClassNew(obj, new_style) { //v2.6 by PVII
obj.className=new_style;
}
function toggleMarker()
{
//alert("Toggle");
var marker = MM_findObj("markerImg");
//alert(marker.src);
if(marker != null && marker.src != null) {
//alert(marker.src);
if(marker.src.indexOf("t_black.gif")>0) {
marker.src = "t_white.gif";
}
else
marker.src = "t_black.gif";
//alert(marker.src);
editor.toggleMarker();
}
}
function updateMarker(mode)
{
if (mode == 'crop')
{
var t_cx = MM_findObj('cx');
var t_cy = MM_findObj('cy');
var t_cw = MM_findObj('cw');
var t_ch = MM_findObj('ch');
editor.setMarker(parseInt(t_cx.value), parseInt(t_cy.value), parseInt(t_cw.value), parseInt(t_ch.value));
}
else if(mode == 'scale') {
var s_sw = MM_findObj('sw');
var s_sh = MM_findObj('sh');
editor.setMarker(0, 0, parseInt(s_sw.value), parseInt(s_sh.value));
}
}
var current_action = null;
var actions = ['crop', 'scale', 'rotate', 'measure', 'save'];
function toggle(action)
{
if(action != current_action) {
var toolbar = MM_findObj('bar_'+action);
var icon = MM_findObj('icon_'+action);
var btn = MM_findObj('btn_'+action);
btn.className='iconsSel';
current_action = action;
toolbar.style.display = "block";
icon.style.display = "block";
for (var i in actions)
{
if(current_action != actions[i]) {
var tool = MM_findObj('bar_'+actions[i]);
tool.style.display = "none";
var icon = MM_findObj('icon_'+actions[i]);
icon.style.display = "none";
var btn = MM_findObj('btn_'+actions[i]);
btn.className = 'icons';
}
}
editor.setMode(current_action);
}
//alert(action);
}
function changeClass(obj,action)
{
if(action == current_action) {
obj.className = 'iconsSel';
}
else
{
obj.className = 'icons';
}
}
function rotatePreset(selection)
{
var value = selection.options[selection.selectedIndex].value;
if(value.length > 0 && parseInt(value) != 0) {
var ra = MM_findObj('ra');
ra.value = parseInt(value);
}
}
function updateFormat(selection)
{
var selected = selection.options[selection.selectedIndex].value;
var values = selected.split(",");
//alert(values.length);
if(values.length >1) {
updateSlider(parseInt(values[1]));
}
}
function onCancel() {
__dlg_close(null);
return false;
};
function onOK()
{
__dlg_close(null);
return false;
}
function Init() {
__dlg_init();
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY onLoad="Init();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" cellspacing="1" >
<tr bgcolor="#EEEEFF" height="40">
<td class="topBar" width="60" ><table width="100%" border="0" cellspacing="8" cellpadding="2">
<tr>
<td class="icons">
<div id="icon_crop" style="display:none">
<img src="crop.gif" alt="Crop" width="20" height="20" border="0">
</div>
<div id="icon_scale" style="display:none">
<img src="scale.gif" alt="Resize" width="20" height="20" border="0">
</div>
<div id="icon_rotate" style="display:none">
<img src="rotate.gif" alt="Rotate" width="20" height="20" border="0">
</div>
<div id="icon_measure" style="display:none">
<img src="ruler.gif" alt="Measure" width="20" height="20" border="0">
</div>
<div id="icon_save" style="display:none">
<img src="save.gif" alt="Save" width="20" height="20" border="0">
</div>
</td>
</tr>
</table></td>
<td>
<!-- crop -->
<div id="bar_crop" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Start X:
<INPUT TYPE="text" id="cx" style="width:3em" NAME="cx" onChange="updateMarker('crop')">
Start Y:
<INPUT TYPE="text" id="cy" style="width:3em" NAME="cy" onChange="updateMarker('crop')">
Width:
<INPUT TYPE="text" id="cw" style="width:3em" NAME="cw" onChange="updateMarker('crop')">
Height:
<INPUT TYPE="text" id="ch" style="width:3em" NAME="ch" onChange="updateMarker('crop')"> </td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" width="30" alt="Cancel" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('crop');"><img src="btn_ok.gif" alt="Apply" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //crop -->
<!-- measure -->
<div id="bar_measure" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">X:
<span id="sx" class="measureStats"></span>
Y:
<span id="sy" class="measureStats"></span></td>
<td class="topBar"><img src="div.gif" width="2" height="30"></td>
<td class="topBar"> W:
<span id="mw" class="measureStats"></span>
H:
<span id="mh" class="measureStats"></span>
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="topBar">A:
<span id="ma" class="measureStats"></span>
D: <span id="md" class="measureStats"></span>
</td>
<td class="icons"><img src="div.gif" width="2" height="30"></td>
<td class="icons"><input type="button" name="Button" value="Clear" onClick="editor.reset()"></td>
</tr>
</table>
</div>
<!-- //measure -->
<!-- scale -->
<div id="bar_scale" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Width:
<input type="text" id="sw" style="width:3em" name="sw" onChange="updateMarker('scale')">
</td>
<td class="topBar"><img src="locked.gif" width="8" height="14"></td>
<td class="topBar"> Height:
<INPUT TYPE="text" id="sh" style="width:3em" NAME="sh" onChange="updateMarker('scale')">
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" alt="Cancel" width="30" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('scale');"><img src="btn_ok.gif" alt="Apply" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //scale -->
<!-- rotate -->
<div id="bar_rotate" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td width="115" class="topBar"><select id="flip" name="flip">
<option selected>Flip Image</option>
<option>-----------------</option>
<option value="hoz">Flip Horizontal</option>
<option value="ver">Flip Virtical</option>
</select></td>
<td width="115" class="topBar"><select name="rotate" onChange="rotatePreset(this)">
<option selected>Rotate Image</option>
<option>-----------------</option>
<option value="180">Rotate 180 &deg;</option>
<option value="90">Rotate 90 &deg; CW</option>
<option value="-90">Rotate 90 &deg; CCW</option>
</select></td>
<td width="87" class="topBar"> Angle:
<INPUT TYPE="text" id="ra" style="width:3em" NAME="ra" onChange="updateMarker('rotate')">
</td>
<td width="2"><img src="div.gif" width="2" height="30"></td>
<td width="32" class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" alt="Cancel" width="30" height="30" border="0"></a></td>
<td width="32" class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('rotate');"><img src="btn_ok.gif" alt="Apply" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //rotate -->
<!-- save -->
<div id="bar_save" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Filename:
<input type="filename" id="save_filename" value="<? echo $path_info['basename']; ?>" name="textfield"></td>
<td class="topBar"> <select name="format" id="save_format" onChange="updateFormat(this)">
<option value="" selected>Image Format</option>
<option value="">---------------------</option>
<option value="jpeg,85">JPEG High</option>
<option value="jpeg,60">JPEG Medium</option>
<option value="jpeg,35">JPEG Low</option>
<option value="png">PNG</option>
<option value="gif">GIF</option>
</select></td>
<td class="topBar">Quality:
</td>
<td width="120">
<div id="slidercasing">
<div id="slidertrack" style="width:100px"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0" ALT="track"></div>
<div id="sliderbar" style="left:50px" onmousedown="captureStart()"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0" ALT="track"></div></div>
</td>
<td class="topBar">
<INPUT TYPE="text" id="quality" NAME="quality" onChange="updateSlider(this.value)" style="width:2em">
<script type="text/javascript" src="jscripts/slider.js"></script>
<script language="JavaScript1.2">
<!--
updateSlider(85);
//-->
</script>
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" alt="Cancel" width="30" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('save');"><img src="btn_ok.gif" alt="Apply" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!--//save -->
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF" width="60" valign="top" align="center" nowrap><table width="100%" border="0" cellspacing="8" cellpadding="2">
<tr>
<td class="icons" id='btn_crop' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'crop')"><a href="#" class="iconText" onClick="javascript:toggle('crop')"><img src="crop.gif" alt="Crop" width="20" height="20" border="0"><br>
Crop</a> </td>
</tr>
<tr>
<td class="icons" id='btn_scale' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'scale')"><a href="#" class="iconText" onClick="javascript:toggle('scale')"><img src="scale.gif" alt="Resize" width="20" height="20" border="0"><br>
Resize</a> </td>
</tr>
<tr>
<td class="icons" id='btn_rotate' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'rotate')"><a href="#" class="iconText" onClick="javascript:toggle('rotate')"><img src="rotate.gif" alt="Rotate" width="20" height="20" border="0"><br>
Rotate</a> </td>
</tr>
<tr>
<td class="icons" id='btn_measure' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'measure')"><a href="#" class="iconText" onClick="javascript:toggle('measure')"><img src="ruler.gif" alt="Measure" width="20" height="20" border="0"><br>
Measure</a></td>
</tr>
<tr>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a class="iconText" href="#" onClick="toggleMarker();"><img src="t_black.gif" name="markerImg" id="markerImg" alt="Marker" width="20" height="20" border="0"><br>
Marker</a></td>
</tr>
<tr>
<td class="icons" id='btn_save' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'save')"><a href="#" class="iconText" onClick="javascript:toggle('save')"><img src="save.gif" alt="Save" width="20" height="20" border="0"><br>
Save</a> </td>
</tr>
</table>
</td>
<td width="99%" >
<iframe width="100%" height="100%" id="editor" name="editor" src="load_image.php?img=<? echo $image; ?>" marginwidth="0" marginheight="0" align="top" scrolling="auto" frameborder="0" hspace="0" vspace="0" background="gray">
</iframe>
</td>
</tr>
</table>
</BODY>
</HTML>

View File

@ -0,0 +1,254 @@
<?php
/***********************************************************************
** Title.........: NetPBM Driver
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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 <peter@mapledesign.co.uk> |
// +----------------------------------------------------------------------+
//
// $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
?>

View File

@ -0,0 +1,569 @@
<?php
/***********************************************************************
** Title.........: Image Transformation Interface
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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 <peter@mapledesign.co.uk> |
// | Alan Knowles <alan@akbkhome.com> |
// | Vincent Oostindie <vincent@sunlight.tmfweb.nl> |
// +----------------------------------------------------------------------+
//
// $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 <peter@mapledesign.co.uk>
* @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)."<br>";
//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);
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

View File

@ -0,0 +1,694 @@
/***********************************************************************
** Title.........: Online Image Editor Interface
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var pic_x, pic_y;
function P7_Snap() { //v2.62 by PVII
var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=P7_Snap.arguments;a=parseInt(a);
for (k=0; k<(args.length-3); k+=4)
if ((g=MM_findObj(args[k]))!=null) {
el=eval(MM_findObj(args[k+1]));
a=parseInt(args[k+2]);b=parseInt(args[k+3]);
x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']";
if(document.getElementById) {
d="document.getElementsByName('"+args[k]+"')[0]";
if(!eval(d)) {d="document.getElementById('"+args[k]+"')";if(!eval(d)) {d=da;}}
}else if(document.all) {d=da;}
if (document.all || document.getElementById) {
while (tx==1) {p+=".offsetParent";
if(eval(d+p)) {x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
}else{tx=0;}}
ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy;
if(tw==0 || (navigator.appVersion.indexOf("MSIE 4")>-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;s<q0.length;s++) {dd='document.'+q0[s].name;
if(eval(dd+'.document.'+args[k])) {x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}}
if(el) {e=(document.layers)?el:el.style;
var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
//alert(xx+":"+yy);
if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4){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 + "&deg; ";
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+ah<pic_y+pic_height?ch:ch-(ay+ah-pic_y-pic_height);
cw = ax+aw<pic_x+pic_width?cw:cw-(ax+aw-pic_x-pic_width);
ch = ch<0?0:ch; cw = cw<0?0:cw;
if (ant.style.visibility == "hidden")
{
cx = ""; cy = ""; cw=""; ch="";
}
if(mode == 'crop') {
if(t_cx != null)
t_cx.value = cx;
if (t_cy != null)
t_cy.value = cy;
if(t_cw != null)
t_cw.value = cw;
if (t_ch != null)
t_ch.value = ch;
}
else if(mode == 'scale') {
var sw = aw, sh = ah;
if (s_sw.value.indexOf('%')>0 && 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;

View File

@ -0,0 +1,104 @@
/***********************************************************************
** Title.........: Simple Lite Slider for Image Editor
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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;
}

View File

@ -0,0 +1,921 @@
/***********************************************************************
** Title.........: Javascript Graphics
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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 <walter@kreuzotter.de>
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 style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;background-color:' + this.color + ';'+
'"><\/div>';
//alert(this.htm);
}
function mkDivPrint(x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'border-left:' + w + 'px solid ' + this.color + ';'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;background-color:' + this.color + ';'+
'"><\/div>';
}
function mkLyr(x, y, w, h)
{
this.htm += '<layer '+
'left="' + x + '" '+
'top="' + y + '" '+
'width="' + w + '" '+
'height="' + h + '" '+
'bgcolor="' + this.color + '"><\/layer>\n';
}
function mkLbl(txt, x, y)
{
this.htm += '<div style="position:absolute;white-space:nowrap;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'font-family:' + this.ftFam + ';'+
'font-size:' + this.ftSz + ';'+
'color:' + this.color + ';' + this.ftSty + '">'+
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 style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'overflow:hidden;'+
//'background-color:' + this.color + ';'+
"background-image: url('" + url + "');"+
"layer-background-image: url('" + url + "');"+
'z-index:100;"><\/div>';
//alert(this.htm);
}
this.drawHandle = function(x, y, w, h, cursor)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'padding: 2px;overflow:hidden;'+
"cursor: '" + cursor + "';"+
'" class="handleBox" id="' + cursor + '" ><\/div>';
}
this.drawHandleBox = function(x, y, w, h, cursor)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+(w+2)+'px,'+(h+2)+'px,0);'+
'overflow:hidden; border: solid 1px '+ this.color+';'+
"cursor: '" + cursor + "';"+
'" class="handleBox" id="' + cursor + '" ><\/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;
}
}

View File

@ -0,0 +1,138 @@
<?
/***********************************************************************
** Title.........: Online Manipulation of Images
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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';
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

View File

@ -0,0 +1,131 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script type="text/javascript" src="jscripts/wz_jsgraphics.js"></script>
<script type="text/javascript" src="jscripts/EditorContent.js"></script>
<style>
<!--
.crop{cursor:crosshair;}
.selection{
border: dotted 1px #000000;
position:absolute;
width: 0px;
height: 1px;
z-index:5;
}
.selectionWhite{
border: dotted 1px #FFFFFF;
position:absolute;
width: 0px;
height: 1px;
z-index:5;
}
.handleBox{
z-index:105;
}
-->
</style>
<script type="text/javascript">
var t_cx = MM_findObj('cx', window.top.document);
var t_cy = MM_findObj('cy', window.top.document);
var t_cw = MM_findObj('cw', window.top.document);
var t_ch = MM_findObj('ch', window.top.document);
var m_sx = MM_findObj('sx', window.top.document);
var m_sy = MM_findObj('sy', window.top.document);
var m_w = MM_findObj('mw', window.top.document);
var m_h = MM_findObj('mh', window.top.document);
var m_a = MM_findObj('ma', window.top.document);
var m_d = MM_findObj('md', window.top.document);
var s_sw = MM_findObj('sw', window.top.document);
var s_sh = MM_findObj('sh', window.top.document);
var r_ra = MM_findObj('ra', window.top.document);
var mode = "<? echo $action; ?>" //crop, scale, measure
var pattern = "2x2.gif";
function doSubmit(action)
{
var image = escape("<? echo $path.$image; ?>");
if (action == 'crop')
{
var url = "load_image.php?img="+image+"&action=crop&params="+parseInt(t_cx.value)+','+parseInt(t_cy.value)+','+ parseInt(t_cw.value)+','+parseInt(t_ch.value);
//alert(url);
location.href = url;
//location.reload();
}
else if (action == 'scale')
{
var url = "load_image.php?img="+image+"&action=scale&params="+parseInt(s_sw.value)+','+parseInt(s_sh.value);
//alert(url);
location.href = url;
}
else if (action == 'rotate')
{
var flip = MM_findObj('flip', window.top.document);
if(flip.value == 'hoz' || flip.value == 'ver')
location.href = "load_image.php?img="+image+"&action=flip&params="+flip.value;
else if (isNaN(parseFloat(r_ra.value))==false)
location.href = "load_image.php?img="+image+"&action=rotate&params="+parseFloat(r_ra.value);
}
else if(action == 'save') {
var s_file = MM_findObj('save_filename', window.top.document);
var s_format = MM_findObj('save_format', window.top.document);
var s_quality = MM_findObj('quality',window.top.document);
var format = s_format.value.split(",");
if(s_file.value.length <= 0) {
alert('Please enter a filename to save.');
}
else
{
var filename = escape(s_file.value);
var quality = parseInt(s_quality.value);
var url = "load_image.php?img="+image+"&action=save&params="+format[0]+","+quality+"&file="+filename;
//alert(url);
location.href = url;
}
}
}
</script>
</HEAD>
<BODY bgcolor="#CCCCCC" onLoad="init();">
<div id="status"></div>
<div id="ant" class="selection" style="visibility:hidden"><IMG SRC="spacer.gif" WIDTH="0" HEIGHT="0" BORDER="0" ALT="" id="cropContent"></div>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<Tr height="100%">
<Td align="center" height="100%">
<span id="imgCanvas" class="crop"><IMG SRC="<? echo $path.$image; ?>" <? echo $dimensions; ?> BORDER=0 ALT="" id="theImage" name="theImage"></span>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
var jg_doc = new jsGraphics("imgCanvas"); // draw directly into document
jg_doc.setColor("#000000"); // black
<?
if(isset($save_file) && is_file($BASE_DIR.$path.$save_file)) {
echo "alert('$save_file saved')";
}
?>
//-->
</script>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

View File

@ -0,0 +1,332 @@
<html style="width:580px; height:550;">
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link href="ImageEditor.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function pviiClassNew(obj, new_style) { //v2.6 by PVII
obj.className=new_style;
}
function toggleMarker()
{
//alert("Toggle");
var marker = MM_findObj("markerImg");
//alert(marker.src);
if(marker != null && marker.src != null) {
//alert(marker.src);
if(marker.src.indexOf("t_black.gif")>0) {
marker.src = "t_white.gif";
}
else
marker.src = "t_black.gif";
//alert(marker.src);
editor.toggleMarker();
}
}
function updateMarker(mode)
{
if (mode == 'crop')
{
var t_cx = MM_findObj('cx');
var t_cy = MM_findObj('cy');
var t_cw = MM_findObj('cw');
var t_ch = MM_findObj('ch');
editor.setMarker(parseInt(t_cx.value), parseInt(t_cy.value), parseInt(t_cw.value), parseInt(t_ch.value));
}
else if(mode == 'scale') {
var s_sw = MM_findObj('sw');
var s_sh = MM_findObj('sh');
editor.setMarker(0, 0, parseInt(s_sw.value), parseInt(s_sh.value));
}
}
var current_action = null;
var actions = ['crop', 'scale', 'rotate', 'measure', 'save'];
function toggle(action)
{
if(action != current_action) {
var toolbar = MM_findObj('bar_'+action);
var icon = MM_findObj('icon_'+action);
var btn = MM_findObj('btn_'+action);
btn.className='iconsSel';
current_action = action;
toolbar.style.display = "block";
icon.style.display = "block";
for (var i in actions)
{
if(current_action != actions[i]) {
var tool = MM_findObj('bar_'+actions[i]);
tool.style.display = "none";
var icon = MM_findObj('icon_'+actions[i]);
icon.style.display = "none";
var btn = MM_findObj('btn_'+actions[i]);
btn.className = 'icons';
}
}
editor.setMode(current_action);
}
//alert(action);
}
function changeClass(obj,action)
{
if(action == current_action) {
obj.className = 'iconsSel';
}
else
{
obj.className = 'icons';
}
}
function rotatePreset(selection)
{
var value = selection.options[selection.selectedIndex].value;
if(value.length > 0 && parseInt(value) != 0) {
var ra = MM_findObj('ra');
ra.value = parseInt(value);
}
}
function updateFormat(selection)
{
var selected = selection.options[selection.selectedIndex].value;
var values = selected.split(",");
//alert(values.length);
if(values.length >1) {
updateSlider(parseInt(values[1]));
}
}
var editImage = '';
if(location.href.indexOf('?')>0) {
var parameters = location.href.split('?');
editImage = parameters[1];
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" cellspacing="1" >
<tr bgcolor="#EEEEFF" height="40">
<td class="topBar" width="60" ><table width="100%" border="0" cellspacing="8" cellpadding="2">
<tr>
<td class="icons">
<div id="icon_crop" style="display:none">
<img src="crop.gif" width="20" height="20" border="0">
</div>
<div id="icon_scale" style="display:none">
<img src="scale.gif" width="20" height="20" border="0">
</div>
<div id="icon_rotate" style="display:none">
<img src="rotate.gif" width="20" height="20" border="0">
</div>
<div id="icon_measure" style="display:none">
<img src="ruler.gif" width="20" height="20" border="0">
</div>
<div id="icon_save" style="display:none">
<img src="save.gif" width="20" height="20" border="0">
</div>
</td>
</tr>
</table></td>
<td>
<!-- crop -->
<div id="bar_crop" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Start X:
<INPUT TYPE="text" id="cx" style="width:3em" NAME="cx" onChange="updateMarker('crop')">
Start Y:
<INPUT TYPE="text" id="cy" style="width:3em" NAME="cy" onChange="updateMarker('crop')">
Width:
<INPUT TYPE="text" id="cw" style="width:3em" NAME="cw" onChange="updateMarker('crop')">
Height:
<INPUT TYPE="text" id="ch" style="width:3em" NAME="ch" onChange="updateMarker('crop')"> </td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" width="30" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('crop');"><img src="btn_ok.gif" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //crop -->
<!-- measure -->
<div id="bar_measure" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">X:
<span id="sx" class="measureStats"></span>
Y:
<span id="sy" class="measureStats"></span></td>
<td class="topBar"><img src="div.gif" width="2" height="30"></td>
<td class="topBar"> W:
<span id="mw" class="measureStats"></span>
H:
<span id="mh" class="measureStats"></span>
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="topBar">A:
<span id="ma" class="measureStats"></span>
D: <span id="md" class="measureStats"></span>
</td>
<td class="icons"><img src="div.gif" width="2" height="30"></td>
<td class="icons"><input type="button" name="Button" value="Clear" onClick="editor.reset()"></td>
</tr>
</table>
</div>
<!-- //measure -->
<!-- scale -->
<div id="bar_scale" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Width:
<input type="text" id="sw" style="width:3em" name="sw" onChange="updateMarker('scale')">
</td>
<td class="topBar"><img src="locked.gif" width="8" height="14"></td>
<td class="topBar"> Height:
<INPUT TYPE="text" id="sh" style="width:3em" NAME="sh" onChange="updateMarker('scale')">
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" width="30" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('scale');"><img src="btn_ok.gif" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //scale -->
<!-- rotate -->
<div id="bar_rotate" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td width="115" class="topBar"><select id="flip" name="flip">
<option selected>Flip Image</option>
<option>-----------------</option>
<option value="hoz">Flip Horizontal</option>
<option value="ver">Flip Virtical</option>
</select></td>
<td width="115" class="topBar"><select name="rotate" onChange="rotatePreset(this)">
<option selected>Rotate Image</option>
<option>-----------------</option>
<option value="180">Rotate 180 &deg;</option>
<option value="90">Rotate 90 &deg; CW</option>
<option value="-90">Rotate 90 &deg; CCW</option>
</select></td>
<td width="87" class="topBar"> Angle:
<INPUT TYPE="text" id="ra" style="width:3em" NAME="ra" onChange="updateMarker('rotate')">
</td>
<td width="2"><img src="div.gif" width="2" height="30"></td>
<td width="32" class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" width="30" height="30" border="0"></a></td>
<td width="32" class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('rotate');"><img src="btn_ok.gif" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!-- //rotate -->
<!-- save -->
<div id="bar_save" style="display:none">
<table border="0" cellspacing="5" cellpadding="2">
<tr>
<td class="topBar">Filename:
<input type="filename" id="save_filename" value="padpc_1.jpg" name="textfield"></td>
<td class="topBar"> <select name="format" id="save_format" onChange="updateFormat(this)">
<option selected>Image Format</option>
<option>---------------------</option>
<option value="jpeg,85">JPEG High</option>
<option value="jpeg,60">JPEG Medium</option>
<option value="jpeg,35">JPEG Low</option>
<option value="png">PNG</option>
<option value="gif">GIF</option>
</select></td>
<td class="topBar">Quality:
</td>
<td width="120">
<div id="slidercasing">
<div id="slidertrack" style="width:100px"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0" ALT="track"></div>
<div id="sliderbar" style="left:50px" onmousedown="captureStart()"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0" ALT="track"></div></div>
</td>
<td class="topBar">
<INPUT TYPE="text" id="quality" NAME="quality" onChange="updateSlider(this.value)" style="width:2em">
<script type="text/javascript" src="jscripts/slider.js"></script>
<script language="JavaScript1.2">
<!--
updateSlider(85);
//-->
</script>
</td>
<td><img src="div.gif" width="2" height="30"></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.reset();"><img src="btn_cancel.gif" width="30" height="30" border="0"></a></td>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a href="#" onClick="editor.doSubmit('save');"><img src="btn_ok.gif" width="30" height="30" border="0"></a></td>
</tr>
</table>
</div>
<!--//save -->
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF" width="60" valign="top" align="center" nowrap><table width="100%" border="0" cellspacing="8" cellpadding="2">
<tr>
<td class="icons" id='btn_crop' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'crop')"><a href="#" class="iconText" onClick="javascript:toggle('crop')"><img src="crop.gif" width="20" height="20" border="0"><br>
Crop</a> </td>
</tr>
<tr>
<td class="icons" id='btn_scale' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'scale')"><a href="#" class="iconText" onClick="javascript:toggle('scale')"><img src="scale.gif" width="20" height="20" border="0"><br>
Resize</a> </td>
</tr>
<tr>
<td class="icons" id='btn_rotate' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'rotate')"><a href="#" class="iconText" onClick="javascript:toggle('rotate')"><img src="rotate.gif" width="20" height="20" border="0"><br>
Rotate</a> </td>
</tr>
<tr>
<td class="icons" id='btn_measure' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'measure')"><a href="#" class="iconText" onClick="javascript:toggle('measure')"><img src="ruler.gif" width="20" height="20" border="0"><br>
Measure</a></td>
</tr>
<tr>
<td class="icons" onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="pviiClassNew(this,'icons')"><a class="iconText" href="#" onClick="toggleMarker();"><img src="t_black.gif" name="markerImg" id="markerImg" width="20" height="20" border="0"><br>
Marker</a></td>
</tr>
<tr>
<td class="icons" id='btn_save' onMouseOver="pviiClassNew(this,'iconsOver')" onMouseOut="changeClass(this,'save')"><a href="#" class="iconText" onClick="javascript:toggle('save')"><img src="save.gif" width="20" height="20" border="0"><br>
Save</a> </td>
</tr>
</table>
</td>
<td width="99%" >
<iframe width="100%" height="100%" id="editor" name="editor" src="load_image.php" marginwidth="0" marginheight="0" align="top" scrolling="auto" frameborder="0" hspace="0" vspace="0" background="gray">
</iframe>
</td>
</tr>
</table>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

View File

@ -0,0 +1,55 @@
<?
//************************** BEGIN CONFIGURATION *****************************//
//example, this is the actual file system path
//of the web server document root. e.g.
// Filesystem == /home/web/www.yourdomain.com
$BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
//the path where the browser sees the document root (i.e. http://www.yourdomain.com/)
$BASE_URL = '/';
//this is where the images will be stored relative to the $BASE_DIR (and $BASE_URL)
//this directory MUST be readable AND writable by the web server.
$BASE_ROOT = 'test';
//The image manipulation library to use, either GD or ImageMagick or NetPBM
//valid definitions are 'GD' or 'IM' or 'NetPBM'.
define('IMAGE_CLASS', 'GD'); //
//After defining which library to use, if it is NetPBM or IM, you need to
//specify where the binary for the selected library are. And of course
//your server and PHP must be able to execute them (i.e. safe mode is OFF).
//If you have safe mode ON, or don't have the binaries, your choice is
//GD only. GD does not require the following definition.
define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/');
//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\');
//In safe mode, directory creation is not permitted.
$SAFE_MODE = false;
//************************** END CONFIGURATION *****************************//
$IMG_ROOT = $BASE_ROOT;
if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1)
$BASE_DIR .= '/';
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
$BASE_URL .= '/';
//Built in function of dirname is faulty
//It assumes that the directory nane can not contain a . (period)
function dir_name($dir)
{
$lastSlash = intval(strrpos($dir, '/'));
if($lastSlash == strlen($dir)-1){
return substr($dir, 0, $lastSlash);
}
else
return dirname($dir);
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,658 @@
<?
/***********************************************************************
** Title.........: Image Manager, draws the thumbnails and directies
** Version.......: 1.01
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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.'<br>';
rm_all_dir($del_folder);
$refresh_dirs = true;
}
}
function rm_all_dir($dir)
{
//$dir = dir_name($dir);
//echo "OPEN:".$dir.'<Br>';
if(is_dir($dir))
{
$d = @dir($dir);
while (false !== ($entry = $d->read()))
{
//echo "#".$entry.'<br>';
if($entry != '.' && $entry != '..')
{
$node = $dir.'/'.$entry;
//echo "NODE:".$node;
if(is_file($node)) {
//echo " - is file<br>";
unlink($node);
}
else if(is_dir($node)) {
//echo " - is Dir<br>";
rm_all_dir($node);
}
}
}
$d->close();
rmdir($dir);
}
//echo "RM: $dir <br>";
}
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."<br>";
if(substr($entry,0,1) != '.') {
$total++;
}
}
$d->close();
}
return $total;
}
function dirs($dir,$abs_path)
{
$d = dir($dir);
//echo "Handle: ".$d->handle."<br>\n";
//echo "Path: ".$d->path."<br>\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."<br>\n";
$path['path'] = $dir.'/'.$entry;
$path['name'] = $entry;
$dirs[$entry] = $path;
}
}
$d->close();
ksort($dirs);
for($i=0; $i<count($dirs); $i++)
{
$name = key($dirs);
$current_dir = $abs_path.'/'.$dirs[$name]['name'];
echo ", \"$current_dir\"\n";
dirs($dirs[$name]['path'],$current_dir);
next($dirs);
}
}
function parse_size($size)
{
if($size < 1024)
return $size.' btyes';
else if($size >= 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);
?>
<td>
<table width="102" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
<a href="javascript:;" onClick="javascript:imageSelected('<? echo $img_url; ?>', <? echo $info[0];?>, <? echo $info[1]; ?>,'<? echo $file; ?>');"><img src="<? echo $thumb_image; ?>" alt="<? echo $file; ?> - <? echo $filesize; ?>" border="0"></a></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
<a href="javascript:;" onClick="javascript:preview('<? echo $img_url; ?>', '<? echo $file; ?>', ' <? echo $filesize; ?>',<? echo $info[0].','.$info[1]; ?>);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td>
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
<a href="images.php?delFile=<? echo $img_url; ?>&dir=<? echo $newPath; ?>" onClick="return deleteImage('<? echo $file; ?>');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
<td width="98%" class="imgCaption"><? echo $info[0].'x'.$info[1]; ?></td>
</tr>
</table></td>
</tr>
</table>
</td>
<?
}
function show_dir($path, $dir)
{
global $newPath, $BASE_DIR, $BASE_URL;
$num_files = num_files($BASE_DIR.$path);
?>
<td>
<table width="102" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
<a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')">
<img src="folder.gif" width="80" height="80" border=0 alt="<? echo $dir; ?>">
</a>
</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
<a href="images.php?delFolder=<? echo $BASE_URL.$path; ?>&dir=<? echo $newPath; ?>" onClick="return deleteFolder('<? echo $dir; ?>', <? echo $num_files; ?>);"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
<td width="99%" class="imgCaption"><? echo $dir; ?></td>
</tr>
</table></td>
</tr>
</table>
</td>
<?
}
function draw_no_results()
{
?>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;">No Images Found</div></td>
</tr>
</table>
<?
}
function draw_no_dir()
{
global $BASE_DIR, $BASE_ROOT;
?>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">Configuration Problem: &quot;<? echo $BASE_DIR.$BASE_ROOT; ?>&quot; does not exist.</div></td>
</tr>
</table>
<?
}
function draw_table_header()
{
echo '<table border="0" cellpadding="0" cellspacing="2">';
echo '<tr>';
}
function draw_table_footer()
{
echo '</tr>';
echo '</table>';
}
?>
<html>
<head>
<title>Image Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.imgBorder {
height: 96px;
border: 1px solid threedface;
vertical-align: middle;
}
.imgBorderHover {
height: 96px;
border: 1px solid threedface;
vertical-align: middle;
background: #FFFFCC;
cursor: hand;
}
.buttonHover {
border: 1px solid;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
cursor: hand;
background: #FFFFCC;
}
.buttonOut
{
border: 1px solid;
border-color: white;
}
.imgCaption {
font-size: 9pt;
font-family: "MS Shell Dlg", Helvetica, sans-serif;
text-align: center;
}
.dirField {
font-size: 9pt;
font-family: "MS Shell Dlg", Helvetica, sans-serif;
width:110px;
}
-->
</style>
<?
$dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
$paths = explode('/', $dirPath);
$upDirPath = '/';
for($i=0; $i<count($paths)-2; $i++)
{
$path = $paths[$i];
if(strlen($path) > 0)
{
$upDirPath .= $path.'/';
}
}
$slashIndex = strlen($dirPath);
$newPath = $dirPath;
if($slashIndex > 1 && substr($dirPath, $slashIndex-1, $slashIndex) == '/')
{
$newPath = substr($dirPath, 0,$slashIndex-1);
}
?>
<script type="text/javascript" src="../popup.js"></script>
<script type="text/javascript" src="../../../../dialog.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
function pviiClassNew(obj, new_style) { //v2.6 by PVII
obj.className=new_style;
}
function goUp()
{
location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>";
}
function changeDir(newDir)
{
location.href = "ImageManager/images.php?dir="+newDir;
}
function newFolder(oldDir, newFolder)
{
location.href = "ImageManager/images.php?dir="+oldDir+'&create=folder&foldername='+newFolder;
}
function updateDir()
{
var newPath = "<? echo $newPath; ?>";
if(window.top.document.forms[0] != null) {
var allPaths = window.top.document.forms[0].dirPath.options;
//alert("new:"+newPath);
for(i=0; i<allPaths.length; i++)
{
//alert(allPaths.item(i).value);
allPaths.item(i).selected = false;
if((allPaths.item(i).value)==newPath)
{
allPaths.item(i).selected = true;
}
}
<?
if($clearUploads) {
?>
var topDoc = window.top.document.forms[0];
topDoc.upload.value = null;
//topDoc.upload.disabled = true;
<?
}
?>
}
}
<? if ($refresh_dirs) { ?>
function refreshDirs()
{
var allPaths = window.top.document.forms[0].dirPath.options;
var fields = ["/" <? dirs($BASE_DIR.$BASE_ROOT,'');?>];
var newPath = "<? echo $newPath; ?>";
while(allPaths.length > 0)
{
for(i=0; i<allPaths.length; i++)
{
allPaths.remove(i);
}
}
for(i=0; i<fields.length; i++)
{
var newElem = document.createElement("OPTION");
var newValue = fields[i];
newElem.text = newValue;
newElem.value = newValue;
if(newValue == newPath)
newElem.selected = true;
else
newElem.selected = false;
allPaths.add(newElem);
}
}
refreshDirs();
<? } ?>
function imageSelected(filename, width, height, alt)
{
var topDoc = window.top.document.forms[0];
topDoc.f_url.value = filename;
topDoc.f_width.value= width;
topDoc.f_height.value = height;
topDoc.f_alt.value = alt;
topDoc.orginal_width.value = width;
topDoc.orginal_height.value = height;
}
function preview(file, image, size, width, height)
{
/*
var predoc = '<img src="'+file+'" alt="'+image+' ('+width+'x'+height+', '+size+')">';
var w = 450;
var h = 400;
var LeftPosition=(screen.width)?(screen.width-w)/2:100;
var TopPosition=(screen.height)?(screen.height-h)/2:100;
var win = window.open('','image_preview','toolbar=no,location=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition);
var doc=win.document.open();
doc.writeln('<html>\n<head>\n<title>Image Preview - '+image+' ('+width+'x'+height+', '+size+')</title>');
doc.writeln('</head>\n<body>');
doc.writeln(predoc);
doc.writeln('</body>\n</html>\n');
doc=win.document.close();
win.focus();*/
//alert(file);
Dialog("../ImageEditor/ImageEditor.php?img="+escape(file), function(param) {
if (!param) { // user must have pressed Cancel
return false;
}
}, null);
return;
}
function deleteImage(file)
{
if(confirm("Delete image \""+file+"\"?"))
return true;
return false;
}
function deleteFolder(folder, numFiles)
{
if(numFiles > 0) {
alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first.");
return false;
}
if(confirm("Delete folder \""+folder+"\"?"))
return true;
return false;
}
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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
function changeLoadingStatus(state)
{
var statusText = null;
if(state == 'load') {
statusText = 'Loading Images';
}
else if(state == 'upload') {
statusText = 'Uploading Files';
}
if(statusText != null) {
var obj = MM_findObj('loadingStatus', window.top.document);
//alert(obj.innerHTML);
if (obj != null && obj.innerHTML != null)
obj.innerHTML = statusText;
MM_showHideLayers('loading','','show')
}
}
//-->
</script>
</head>
<body onLoad="updateDir();" bgcolor="#FFFFFF">
<?
//var_dump($_GET);
//echo $dirParam.':'.$upDirPath;
//echo '<br>';
$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<count($folders); $i++)
{
$folder_name = key($folders);
show_dir($folders[$folder_name], $folder_name);
next($folders);
}
for($i=0; $i<count($images); $i++)
{
$image_name = key($images);
show_image($images[$image_name]['file'], $image_name, $images[$image_name]['img_info'], $images[$image_name]['size']);
next($images);
}
draw_table_footer();
}
else
{
draw_no_results();
}
}
else
{
draw_no_dir();
}
?>
<script language="JavaScript" type="text/JavaScript">
MM_showHideLayers('loading','','hide')
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View File

@ -0,0 +1,89 @@
<html style="width: 280; height: 150;">
<head>
<title>New Folder</title>
<style type="text/css">
<!--
html, body {
background: ButtonFace;
color: ButtonText;
font: 11px Tahoma,Verdana,sans-serif;
margin: 0px;
padding: 0px;
}
body { padding: 5px; }
table {
font: 11px Tahoma,Verdana,sans-serif;
}
form p {
margin-top: 5px;
margin-bottom: 5px;
}
fieldset { padding: 0px 10px 5px 5px; }
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
button { width: 70px; }
.space { padding: 2px; }
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px;
border-bottom: 1px solid black; letter-spacing: 2px;
}
//-->
</style>
<script type="text/javascript" src="../popup.js"></script>
<script type="text/javascript" src="../../dialog.js"></script>
<script type="text/javascript">
function onCancel() {
__dlg_close(null);
return false;
};
function onOK()
{
// pass data back to the calling window
var fields = ["f_foldername"];
var param = new Object();
for (var i in fields) {
var id = fields[i];
var el = MM_findObj(id);
param[id] = el.value;
}
__dlg_close(param);
return false;
}
function Init() {
__dlg_init();
MM_findObj("f_foldername").focus();
}
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<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
</script>
</head>
<body onload="Init()">
<div class="title">New Folder</div>
<form action="" method="get">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <table border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Folder Name:</td>
<td><input name="foldername" type="text" id="f_foldername"></td>
</tr>
</table></td>
<tr>
<td><div style="text-align: right;">
<hr />
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div></td>
</tr>
</table>
</form>
<p>&nbsp;</p><br />
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

View File

@ -0,0 +1,91 @@
<?php
/***********************************************************************
** Title.........: Thumbnail generator, with cache.
** Version.......: 1.0
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
** 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);
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB