|
Posted by Manish on 05/16/06 15:30
Andy Jeffries wrote:
> On Fri, 12 May 2006 03:20:02 -0700, Manish wrote:
> > The problem is that howmuch times I click on Flip Horizontal , it is done
> > on the original picture, I want it to be on the latest edited one.
> >
> > I tried using session, but it didn't worked
> >
> > if(count($_SESSION["imagers"])) {
> > $imagers = $_SESSION["imagers"][count($_SESSION["imagers"])-1];
> > } else {
> > $image = "photo_full.jpg";
> > $imagers = LoadJpeg($image);
> > }
> > $_SESSION["imagers"][count($_SESSION["imagers"])] = $imagers;
>
> This code should work. Have you tried doing a print_r or var_dump on
> $_SESSION after doing a single operation?
>
> BTW, that last line can be written a lot more simply as:
>
> $_SESSION["imagers"][] = $imagers;
>
> Cheers,
>
>
> Andy
>
>
> --
> Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
> http://www.gphpedit.org | PHP editor for Gnome 2
> http://www.andyjeffries.co.uk | Personal site and photos
------------------------------------------------------------------------------------------------------------------------
With the code as follows
echo "_SESSION = <br /><br />"; var_dump($_SESSION);
echo "<br /><br /><br /><br />";
if(count($_SESSION["imagers"])) {
$imagers = $_SESSION["imagers"][count($_SESSION["imagers"])-1];
} else {
$image = "treesplain.jpg";
$imagers = LoadJpeg($image);
}
if($edittype == "0") {
$changedimagers = $imagers;
unset($_SESSION["imagers"]);
} else if($edittype == "1") {
} else if($edittype == "2") {
if($valtype == "1") {
$changedimagers = flipImage($imagers, 1, 0);
} else if($valtype == "2") {
$changedimagers = flipImage($imagers, 0, 1);
}
}
if($changedimagers) {
$_SESSION["imagers"][count($_SESSION["imagers"])] = $changedimagers;
imagejpeg($changedimagers);
}
echo "_SESSION = <br /><br />"; var_dump($_SESSION);
echo "<br /><br /><br /><br />";
------------------------------------------------------------------------------------------------------------------------
1. Close browser
2. http://localhost/test/manipulation/getpic.php?edittype=0
_SESSION =
array(0) { }
{Random characters, for image}
array(1) { ["imagers"]=> array(1) { [0]=> resource(3) of type (gd) } }
3. Change the URL in same browser to
http://localhost/test/manipulation/getpic.php?edittype=2&valtype=1
_SESSION =
array(1) { ["imagers"]=> array(1) { [0]=> int(0) } }
Warning: imagesx(): supplied argument is not a valid Image resource in
c:\program files\easyphp1-8\www\test\manipulation\getpic.php on line 63
Warning: imagesy(): supplied argument is not a valid Image resource in
c:\program files\easyphp1-8\www\test\manipulation\getpic.php on line 64
Warning: imagecreatetruecolor(): Invalid image dimensions in c:\program
files\easyphp1-8\www\test\manipulation\getpic.php on line 69
_SESSION =
array(1) { ["imagers"]=> array(1) { [0]=> int(0) } }
------------------------------------------------------------------------------------------------------------------------
To solve the problem, I save all the steps in the session and redo
steps 1 to current one all over again.
$_SESSION['imagersop'][count($_SESSION['imagersop'])] = array(
"edittype"=>$edittype, "valtype"=>$valtype, "valvalue"=>$valvalue,
);
for($step=0; $step<count($_SESSION['imagersop']); $step++) {
$edittype = $_SESSION['imagersop'][$step]['edittype'];
$valtype = $_SESSION['imagersop'][$step]['valtype'];
$valvalue = $_SESSION['imagersop'][$step]['valvalue'];
-------------
}
One can understand that after about 10 steps, it's really slow as all
steps has to be re performed.
I didn't find any other solution, so I implement this. But some other
way has to be there.
May be we can limit the history to first + (latest 6) + last in
session.
Some more response is required in,
1. brightness, contrast
I do not want to save the image as in imagefilter, but to temporary
store it as with rotate and flipping
2. sharpening issues
i got this code phpUnsharpMask from somewhere in the internet, but
no change is visible for any parameters.
see the code in my next post.
Thanks.
Navigation:
[Reply to this message]
|