Current location: Hot Scripts Forums » Programming Languages » PHP » 12cropimage script ???


12cropimage script ???

Reply
  #1 (permalink)  
Old 08-15-03, 12:14 PM
cjevil cjevil is offline
New Member
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
12cropimage script ???

Hi there,

I still have some problems left with the script. maybe anyone can help me ?

In the 12cropimage.php file there is the following content: (modified by me)

$partypicture = $HTTP_GET_VARS['partypicture'];
$memberpicture = $userid.'_pic'.$fotoid.'.jpg';

//original part of the file
$org = "../../upload/".$partypicture; //where the original can be found (incl fullpath);
$res = "../../upload/".$memberpicture; //how the result should be saved (incl fullpath);


My Problem is: The $org does not get the name of the file if i try to get it dynamically ($partypicture). When I used a static filename (e.g. party01.jpg") it worked. And when I make echo $partypicture the correct filename appears.


Does anybody have any idea what the problem could be??

So long and thanx

CJ
Reply With Quote
  #2 (permalink)  
Old 08-15-03, 08:33 PM
support@deltascripts.com support@deltascripts.com is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi cjevil

Where did you try echo $parypicture ?

Can´t you just use $partypicture without getting the content from $HTTP_GET_VARS['partypicture']; ?

I do not know this program, but..

Regards
__________________
-------------------------------
Are Haugsdal
DeltaScripts Developer
<a href="http://deltascripts.com">DeltaScripts.com - PHP Classifieds</a>
Reply With Quote
  #3 (permalink)  
Old 08-16-03, 04:28 AM
cjevil cjevil is offline
New Member
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
i tryed it at the beginning of the script after the decleration of $partypicture.

the only problem left with the script is that it doesn't work dynamic.

i even try to compare the the static and the dynamic $partypicture variable , and their both the same ,

maybe i have to change something with the script but what:

here is the script maybe anybody has an idea ?

and the variable$memberbild works


<?php

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// //////////////////////////
////////////////////////// 1 2 CROP IMAGE //////////////////////////
////////////////////////// //////////////////////////
////////////////////////// (c) 2002 Roel Meurders //////////////////////////
////////////////////////// mail: scripts@roelmeurders.com //////////////////////////
////////////////////////// version 0.2 //////////////////////////
////////////////////////// //////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
///// CREDITS: Most Javascript is taken from DHTMLCentral.com and is made by Thomas Brattli. ///////
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// SET VARIABLES ///////////////////////////////////////////////////////////////////////////////////

$tempfoto = $HTTP_GET_VARS['partybild'];
$fotoid = $HTTP_GET_VARS['fotoid'];
$userid = $HTTP_GET_VARS['userid'];
$catnr = $HTTP_GET_VARS['catnr'];
$seqnr = $HTTP_GET_VARS['seqnr'];

if ($fotoid == 1){
$memberbild =$userid.'_pic.jpg';
}else{
$memberbild = $userid.'_pic'.$fotoid.'.jpg';
}

$org = "../../upload/party/full/".$tempfoto; //where the original can be found (incl fullpath);
$res = "../../upload/".$memberbild; //how the result should be saved (incl fullpath);
$crw = 112; // sets the heigth to crop to;
$crh = 150; // sets the heigth to crop to;



$maxwinw = 500; //Sets the maxmimum width for displaying the original while cropping
$maxwinh = 500; //Same, only this time it's the height

$jpegqual = 80; //Sets the jpeg quality
$redirect = "12cropimage.php"; //Sets the file to which the forms should be posted Change you include this file in another.
$javafile = "12cropimage.js"; //Relative path to js-file
$gdversion = 2; // set to 2 if you have gd2 installed
$spacer = "spacer.gif"; //Relactive path tpo spacer.gif, transparent image

$txt['cropimage'] = "ausschneiden";
$txt['preview'] = "Vorschau";
$txt['bigger'] = "+";
$txt['smaller'] = "-";
$txt['closewindow'] = "Fenster schließen";
$txt['selectioninpicture'] = "Die Auswahl muß das Bild betreffen.";


////////////////////////////////////////////////////////////////////////////////////////////////////
// GET PROPORTIONS /////////////////////////////////////////////////////////////////////////////////

if ($crA != "nada"){
$size = getimagesize($org);
$trueW=$size[0];
$trueH=$size[1];

if($trueH<$maxwinh && $trueW<$maxwinw){
$imgH = $trueH;
$imgW = $trueW;
$imgProp = 1;
} else {
if (($maxwinh/$maxwinw) < ($trueH/$trueW)){
$imgH = $maxwinh;
$imgW = ($maxwinh / $trueH) * $trueW;
$imgProp = $trueH / $imgH;
} else {
$imgW = $maxwinw;
$imgH = ($maxwinw / $trueW) * $trueH;
$imgProp = $trueW / $imgW;
}
}
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO SHOW THE USER INTERFACE /////////////////////////////////////////////////////////////

function CR_showUI(){
global $txt, $imgW, $imgH, $imgProp, $spacer, $redirect, $javafile, $crw, $crh, $org, $res;
?>


<html>
<head>
<title>Crop image</title>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<script language="JavaScript" src="<?=$javafile?>"></script>

<script language="JavaScript">
<!--
function libinit(){
obj=new lib_obj('cropDiv')
obj.dragdrop()
}

function cropCheck(crA){
if ((((obj.x + obj.cr)-11) <= <?=$imgW?>)&&(((obj.y + obj.cb)-11) <= <?=$imgH?>)&&(obj.x >= 11)&&(obj.y >= 11)){
var url = '<?=$redirect?>?&crA='+crA+'&org=<?=$org?>&res=<?= $res?>&crw=<?=$crw?>&crh=<?=$crh?>&l='+(obj.x-11)+'&t='+(obj.y-11)+'&s='+obj.cr;
if (crA == 'pre'){
window.open(url,'prevWin','width=<?=$crw?>,height= <?=$crh?>');
} else {
location.href=url;
}
} else {
alert('<?=$txt['selectioninpicture']?>');
}
}

function stopZoom() {
loop = false;
clearTimeout(zoomtimer);
}

function cropZoom(dir) {
loop = true;
prop = <?=$crh?> / <?=$crw?>;
zoomtimer = null;
direction = dir;
if (loop == true) {
if (direction == "in") {
if ((obj.cr > <?=($crw/$imgProp)?>)&&(obj.cb > <?=($crh/$imgProp)?>)){
cW = obj.cr - 1;
cH = parseInt(prop * cW);
obj.clipTo(0,cW,cH,0,1);
}
} else {
if ((obj.cr < (<?=$imgW?>-5))&&(obj.cb < (<?=$imgH?>-5))){
cW = obj.cr + 1;
cH = parseInt(prop * cW);
obj.clipTo(0,cW,cH,0,1);
}
}
zoomtimer = setTimeout("cropZoom(direction)", 10);
}
}

onload=libinit;
// -->
</script>
<style>
body{font-family:arial,helvetica; font-size:11px}
#cropDiv{ position:absolute; left:11px; top:11px; width:<?=($crw/$imgProp)?>px; height:<?=($crh/$imgProp)?>px; z-index:2; background-image: url(<?=$spacer?>); }
</style>
<link href="../../styles/sqhstyle.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#9dbcfd" text="#000066" link="#000066" alink="#000066" vlink="#000066" marginwidth="10" marginheight="10" topmargin="10" leftmargin="10">


<table width="500" border="0" cellpadding="0" cellspacing="0">

<tr>
<td colspan="2" align="left" valign="top"><IMG SRC="<?=$redirect?>?crA=img&org=<?=$org?>&res=<?=$ res?>&crw=<?=$crw?>&crh=<?=$crh?>" border="0"></td>
</tr>

<tr>
<td colspan="2"><img src="<?=$spacer?>" border=0 height="5" width="5"></td>
</tr>

<tr>
<td width="228" align="right" class="font1">
<div align="left">
<p class="font1"><font color="#000000"><strong>Profilbild Generator Schritt 2/3</strong></font></p>
</div></td>
<td width="272" align="right">
<input name="Submit1" type="button" class="button" onclick="cropCheck('def');" value="<?=$txt['cropimage']?>">
<input name="Submit2" type="button" class="button" onclick="cropCheck('pre');" value="<?=$txt['preview']?>">
<input name="Submit3" type="button" class="button" onMouseDown="cropZoom('in');" onMouseUp="stopZoom();" value="<?=$txt['smaller']?>">
<input name="Submit4" type="button" class="button" onMouseDown="cropZoom('out');" onMouseUp="stopZoom();" value="<?=$txt['bigger']?>">
</td>
</tr>
<tr>
<td align="right" class="font2"><div align="left"><font color="#000000"></font></div></td>
<td align="right" class="font2">&nbsp;</td>
</tr>
<tr>
<td align="right" class="font2"><div align="left"><font color="#000000"><strong>Wie funktionierts:</strong>&nbsp;&nbsp;</font></div></td>
<td align="right" class="font2">&nbsp;</td>
</tr>
<tr class="font2">
<td colspan="2" align="right" valign="top"><font color="#000000">&nbsp;&nbsp;</font>
<div align="justify"><font color="#000000">Geh mit dem Mauszeiger auf das Rote Rechteck und platzier es an einer gew&uuml;nschten Stelle auf dem Bild. <br>
Um den Ausschnitt zu vergrößern b.z.w zu verkleinern kannst du die <strong>"+"</strong> und die<strong> "-" </strong>Taste benützen. <br>
Mit der Taste <strong>&quot;Vorschau&quot;</strong> kannst du Dein Bild anschauen bevor es hochgeladen wird. <br>
Hast Du eine entg&uuml;ltige Auswahl getroffen, dann kannst Du mit der Taste<strong> &quot;ausschneiden&quot; </strong>Dein Foto in Dein Profil hochladen</font></div></td>
</tr>

</table>

<div id="cropDiv">
<table width="100%" height="100%" border="1" bordercolor="#FF0000" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><img src="<?=$spacer?>"></td>
</tr>
</table>
</div>
</body>
</html>
<?
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO SHOW THE CROP PREVIEW ///////////////////////////////////////////////////////////////

function CR_showPrev($t,$l,$s){
global $txt, $imgW, $imgH, $redirect, $crh, $crw, $org, $res;
?>
<html>
<head>
<title>Vorschau</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="top.focus();">
<a href="#" onClick="top.close();"><img alt="<?=$txt['closewindow']?>" src="<?=$redirect?>?crA=crop&org=<?=$org?>&res=<?= $res?>&crw=<?=$crw?>&crh=<?=$crh?>&l=<?=$l?>&t=<?= $t?>&s=<?=$s?>" border=0></a>
</body>
</html>
<?
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO ACTUALLY MAKE THE CROP //////////////////////////////////////////////////////////////

function CR_make_crop($l,$t,$s,$w,$h){
global $org,$imgProp, $gdversion;
$l1 = ceil($imgProp * $l);
$t1 = ceil($imgProp * $t);
$s1 = ceil($imgProp * $s);
$s2 = ceil(($h / $w)* $s1);
if ($gdversion == 2){
$new = imagecreatetruecolor($w,$h);
} else {
$new = imagecreate($w,$h);
}
$img = imagecreatefromjpeg ($org);
imagecopyresized ($new, $img, 0, 0, $l1, $t1, $w, $h, $s1, $s2);
imagedestroy($img);
return $new;
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// SCRIPT CONTROL VIA VARIABLE $crA ////////////////////////////////////////////////////////////////

switch($crA){
case img:
header("Content-Type: image/jpeg");
$im = CR_make_crop(0,0,($trueW/$imgProp),$imgW,$imgH);
imagejpeg($im,"",$jpegqual);
imagedestroy($im);
exit;
case crop:
header("Content-Type: image/jpeg");
$im = CR_make_crop($l,$t,$s,$crw,$crh);
imagejpeg($im,"",$jpegqual);
imagedestroy($im);
exit;
case pre:
CR_showPrev($t,$l,$s);
exit;
case def:
$org = $HTTP_GET_VARS['org'];
$res = $HTTP_GET_VARS['res'];
$im = CR_make_crop($l,$t,$s,$crw,$crh);
imagejpeg($im,$res,$jpegqual);
imagedestroy($im);
break;
default:
CR_showUI();
exit;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// END OF STORY
?>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a good review management script griz_fan Script Requests 10 07-29-07 05:08 AM
PHP script required Mickey Job Offers & Assistance 8 09-07-03 03:00 PM
Question of the Day script? ncasares PHP 4 08-26-03 07:58 PM
Talkback script..help pls BC_ PHP 0 06-22-03 06:44 PM
Need help with a script boardpix PHP 7 06-08-03 11:37 PM


All times are GMT -5. The time now is 05:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.