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.


mac problem maybe?

 
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
Billy T
Newbie


Joined: 24 Jun 2003
Posts: 3

PostPosted: Tue Jun 24, 2003 8:17 am    Post subject: mac problem maybe? Reply with quote

Hi there

your script is exactly what I was looking for thanks for your efforts Smile

I must be dumb though...it looks so simple but I cant get it to work. Are there any mac related issues? Is there a reason why there is this line

if ($ext == 'jpeg') $saved = $func($this->_imgFinal, $filename, $quality);

but no line for files with an extension of jpg? The line above gives me errors when I run the test script.

I presume all images for the test should just be in the same folder? Also, does the class script have to have the original name because the mac wont let me keep that name...had to change it to cropclass.php

Thanks for any help

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


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

PostPosted: Tue Jun 24, 2003 9:54 am    Post subject: Re: mac problem maybe? Reply with quote

hi Billy - welcome to the board! Smile

Billy T wrote:
your script is exactly what I was looking for thanks for your efforts Smile


Glad you like! Hopefully I (and any other board readers who want a crack at it!) can help sort out the problems you're having...

Billy T wrote:
Are there any mac related issues? Is there a reason why there is this line

if ($ext == 'jpeg') $saved = $func($this->_imgFinal, $filename, $quality);

but no line for files with an extension of jpg?


There are no Mac related issues that I'm aware of. So I guess the first thing we should get from you is your version of PHP and GD that you're using on the Mac.

The reason you're not seeing an extension check for 'jpg' is because the $ext is return via a function that should check for 'jpg' and make it 'jpeg'. Such as:

Code:
$ext = strtolower($this->_getExtension($filename));


This is because when I try to automatically determine the file type from the file name and most people use the 'jpg' extension. However, the GD functions use 'jpeg', such as 'ImageJPEG'. I build up the function name based on the extension (that's the $func() part, obviously) so have to force the jpg->jpeg conversion.

Billy T wrote:
The line above gives me errors when I run the test script.


Could you post up the error message?

Billy T wrote:
I presume all images for the test should just be in the same folder?


Nope, not at all. They have to be all readable, and the folder you write to should be writeable by the script, but they don't have to be in the same location. For example, in one of my scripts I upload an image and resize it (using the dropShadow/thumbnail class of mine) to be 640px wide. I save that in one folder. I then shrink that and crop it (adding a drop shadow too) and save that in another folder. None of the folders are anywhere near my admin scripts.

Billy T wrote:
Also, does the class script have to have the original name because the mac wont let me keep that name...had to change it to cropclass.php


Hmm.. That's odd. Perhaps the Mac doesn't like more than one period in the filename? I've not known that on any Mac I've ever used, but I guess it could be possible.

anyway, even if you had to rename the class file name, so long as you require it in your scripts using that new name it should all work well (assuming we can clear up the problems above, of course! Wink) So, basically, no, it doesn't have to have that original name.

Hope that helps a little bit to answer some of your questions. Post back up and I'll try to help out further.

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


Joined: 24 Jun 2003
Posts: 3

PostPosted: Tue Jun 24, 2003 6:22 pm    Post subject: Reply with quote

amnuts wrote:
the folder you write to should be writeable


Andy - thank you for the friendly welcome and detailed reply!

The line above was the problem - told you I was dumb Confused

As soon as I changed that the errors went away and the cropping and saving worked great!!

I do still have a problem getting an image to show with that test file. I changed it to

PHP:
<?php

    
require 'cropclass.php';
    
$cc = new canvasCrop();
    
$cc->loadImage('final1.jpg');
    
$cc->showImage('jpg','50');

?>


and have it in the same folder as 'final1.jpg' (which is readable) but it won't show.

Also, I noticed when I checked the permissions of the 'final' jpgs that were created by the script that they were all greyed out and I had to turn them on manually - might be a mac thing?

Thanks again for your help!
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Wed Jun 25, 2003 2:05 am    Post subject: Reply with quote

Glad you got it working! Smile (and no, forgetting permissions on a folder isn't dumb at all!)


Billy T wrote:

I do still have a problem getting an image to show with that test file. I changed it to

<?php

require 'cropclass.php';
$cc = new canvasCrop();
$cc->loadImage('final1.jpg');
$cc->showImage('jpg','50');

?>

and have it in the same folder as 'final1.jpg' (which is readable) but it won't show.


You may need to set the content type before you output the image. (a possible oversight of mine not to put them in the showImage method.) So you'll want to have something like this:

Code:
<?php

   require 'cropclass.php';
   $cc = new canvasCrop();
   $cc->loadImage('final1.jpg');
         header('Content-type: image/jpeg');
   $cc->showImage('jpg','50');

?>


Oh course, you'll have to make sure that there is no output prior to that as changing the header type wont work. What I tend to do if I need to mix the image with some text is move the above code into a file and then call that from within an image tag, often passing the filename along as a variable:

Code:
<p>The final image</p>
<img src="showimage.php?file=final1.jpg" border="0" alt="">


That works well.

Billy T wrote:
Also, I noticed when I checked the permissions of the 'final' jpgs that were created by the script that they were all greyed out and I had to turn them on manually - might be a mac thing?


That might very well be a Mac thing. You could always try changing the permissions with the 'chmod' function. this should work in OSX, but I'm not sure about 9 and below.

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


Joined: 24 Jun 2003
Posts: 3

PostPosted: Wed Jun 25, 2003 2:55 am    Post subject: Reply with quote

Thanks again Andy!

When I add the 'header' line it looks a bit more promising as there is the image icon where the picture is meant to show but then I get an 'out of memory error (4k image...1.5gig RAM...should be able to handle it Smile )

Thanks for the tips regarding the chmod function and placing links to php pages within img src tags - I'm new to php so that is very handy to know! If I use this technique and remove the header line from the showimage.php page then I dont get an error but I do get the little 'missing image' logo.

*sigh* so much to learn Shocked

I've upped the files I'm testing with to here - http://www.tableau.com.au/testcrop.zip

if you have time to have a quick look and see if test.php works for you it would be much appreciated

Thanks again

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


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

PostPosted: Wed Jun 25, 2003 3:10 am    Post subject: Reply with quote

Okay, I forgot something.... the method 'showImage' ONLY uses the result image (ie, after you have cropped it), so doing a 'loadImage' followed immediately by the 'showImage' wont work, because the variable '_imgFinal' doesn't have anything in it yet. Instead, try this to test it out:

PHP:
<?php

    
require 'cropclass.php';
    
$cc = new canvasCrop();
    
$cc->loadImage($_GET['file']);
    
header('Content-type: image/jpeg');
    
ImageJPEG($cc->_imgOrig);

?>


That worked for me.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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