andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Can't save?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Thu Feb 05, 2004 1:59 pm    Post subject: Can't save? Reply with quote

Hi,
I'm trying to figure out what I'm doing wrong... I'm passing in a full path to an image, which is "$cropThisPhoto", but when I execute as follows, nothing seems to be happening:

$cc = new canvasCrop();
$cc->loadImage($cropThisPhoto);
$cc->cropToDimensions($left, $top, $right, $bottom);
$cc->saveImage('test.jpg', 90);

Sorry for being a PHP newbie Sad

thanks for any help,

dd
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Feb 05, 2004 2:19 pm    Post subject: Reply with quote

Hi Gringo, and welcome to the board!

First off; no need to apologise for being a PHP newbie!! The PHP community loves to have new users, because soon enough they will be experienced users and able to help out the next load of newbies... So it's a great thing! Smile

I'm assuming that's not your full code, otherwise you're missing off the 'require' statement to include the class. So on that assumption, everything looks okay with the code. That leads me to think it might be a permissions problem. You have to make sure that the web server has permission to write to the directory you're trying to save to, which in your case is the same directory as the class is running in. So try tweaking the directory permissions (with the chmod command if you're running on *nix/*bsd) and see if that helps. Something like:

chmod 766 directory-name-here

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Thu Feb 05, 2004 2:32 pm    Post subject: Reply with quote

thanks Andy. Still having trouble-- here is the complete code:
PHP:
<?php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
>
<
html lang="en">
<
head>
    <
meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <
title>Cropping Image</title>
    <
meta name="generator" content="BBEdit 6.5">
</
head>
<
body>

<?
php

require "class.cropcanvas.php";

//set up vars
$left $left $percentage;
$right =  $right $percentage;
$top =  $top $percentage;
$bottom =  $bottom $percentage;
$left = (integer) $left;
$right = (integer) $right;
$top = (integer) $top;
$bottom = (integer) $bottom;

//show the parameters on-screen to verify...
echo $cropThisPhoto;
echo 
"<br>" .  $top ", " .  $left ", " .  $right ", ".  $bottom ", (" $percentage "%)";

$cc = new canvasCrop();
$cc->loadImage($cropThisPhoto);
$cc->cropToDimensions$left,  $top,  $right,  $bottom);
$cc->saveImage('test.jpg'90);
$cc->showImage('jpg'90);


?>

<?php //try to show results... ?>
<img src="test.jpg">

</body>
</html> ?>


What I'm doing is sending the URL of the image via a POST from another page, along with the dimensions, and a percentage. I have an interface which uses a low-res image to visually crop with, then I'm multiplying all the x,y vars by the percentage to enlarge, to work with the full-sized image. Hope that made sense... At any rate, this page gets the image path and cropping parameters.

I have the directory set to 777; I think that would work?
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Feb 05, 2004 2:44 pm    Post subject: Reply with quote

Hi,

Okay...

1) Do you have register_globals on or off? If t's on then you should see the values printed out for this line:

echo "<br>" . $top . ", " . $left . ", " . $right . ", ". $bottom . ", (" . $percentage . "%)";

Do you see the numbers correctly for that?

2) Have you tried turning on debugging for the script to see if that kicks back any errors? You can do this my initiating the class like:

$cc = new canvasCrop(true);

3) Don't have this line:

$cc->showImage('jpg', 90);

because you've already sent HTML to the browser so your headers are already set and this line at best won't work and at worst will show the binary contents of the image rather than the image itself.

4) Yeah, 777 is totally open so should be able to write there... The debugging may help.

5) What version of PHP are you running, and do you have the GD library installed? You can check all this out by using the 'phpinfo' function in a file, such as:

<?php phpinfo(); ?>

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Thu Feb 05, 2004 3:06 pm    Post subject: Reply with quote

1. yes
2. turned it on; get the message: Error in function loadImage: The supplied file name 'http://www.test.com/client/albums/test/sky4.jpg' does not point to a readable file.
3. removed
4. yep
5. 4.3.3; GD is installed.

so... for some reason it can't open the file... although I can view it in a browser window... the folder "test" which it is getting the file from is chmod 775; is that the problem? I'm not (yet) trying to write it back to that folder.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Feb 05, 2004 3:24 pm    Post subject: Reply with quote

Ahh, okay, we're getting somewhere, I feel! Smile

Don't use a web address for the file - use a path instead, like:

/home/www/client/albums/test/sky4.jpg

or whatever yours happens to be. Give that a whirl and see if it works.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Thu Feb 05, 2004 3:53 pm    Post subject: Reply with quote

thank you! I'll give it a try.
Back to top
View user's profile Send private message
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Fri Feb 06, 2004 8:07 am    Post subject: Reply with quote

OK! I got it to use the server path, and now I get these messages:


Error in function loadImage: That file cannot be loaded with the function 'imagecreatefromjpeg'.

Error in function cropToDimensions: The original image has not been loaded.

Error in function saveImage: There is no processed image to save.


hmmm. The images are optimized jpegs, if that makes a difference...[/b]
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Feb 06, 2004 8:18 am    Post subject: Reply with quote

Hi,

These last two errors stem from the first one. Basically what that's saying is that for one reason or another the image could not initially be loaded. Check the permissions on the file you're trying to load and make sure that the path you're sending to the class is full and exact. Quite often people try a relative path, like '../images/foo.jpg', and it wont always work... best do the full and complete path (making sure the case and everything of the path is correct).

Check out those two issues and see if it helps.

I don't believe the jpg being optimised should cause a problem.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Fri Feb 06, 2004 8:28 am    Post subject: Reply with quote

Andy,

Double-checked the path; it is correct. The enclosing folders are all chmod777, and the actual jpg files are 666--permissions are set by another script that I can't change. 666 is read/write but not execute; that should still work shouldn't it?

still have the same errors.

thanks!
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Feb 06, 2004 8:51 am    Post subject: Reply with quote

Actually, I made a little mistake... That first error is to indicate that the class cannot find the function called 'imagecreatefromjpeg'. I ran into a similar problem at work; GD was installed but the jpeg library wasn't there! Can you check to see in your phpinfo() or gd_info() output if JPG support is active?

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Gringo
Newbie


Joined: 05 Feb 2004
Posts: 7

PostPosted: Fri Feb 06, 2004 2:19 pm    Post subject: Reply with quote

I had some exchanges with the server admin, and sure enough the JPG support was not turned on. Everything is working well now; thanks so much for your support!!!

-dd
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group