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.


It does nothing!

 
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
sderuiter
Newbie


Joined: 26 Nov 2003
Posts: 9

PostPosted: Wed Nov 26, 2003 3:45 am    Post subject: It does nothing! Reply with quote

Hi,

First of all I really like this code. I've copied the class.php file and test.php file to my server (PHP4, GD >1.6.1). After changing a few paths and stuff, I ran the test.php but it outputs nor saves anything.

Code:
include $DOCUMENT_ROOT .'/include/class.cropcanvas.php';
   $cc = new canvasCrop();
   $cc->loadImage  ($DOCUMENT_ROOT . '/reza/daily/reza0007.jpg');
   $cc->cropToDimensions(67, 37, 420, 255);
   $cc->showImage('jpg');




What might be the problem here?

regards,
sderuiter
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 Nov 26, 2003 6:23 am    Post subject: Reply with quote

Hi, and welcome to the board!

Chances are that the reason it's not working is because you have too old a version of GD installed. By default it requires version 2+, and you have 1.6.1+ (which is to say, less than version 1.8, let alone 2!)

If you want to continue to use that version of GD, then check out this thread:

http://php.amnuts.com/forums/viewtopic.php?t=60

as it may prove handy to you in converting the class over.

You may also want to initiate the class with 'true' passed as a parameter. This will turn debugging on and possibly give you a hint as to why it's not working. So you'd have:

Code:
$cc = new canvasCrop(true);


Hope that helps!

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


Joined: 26 Nov 2003
Posts: 9

PostPosted: Wed Nov 26, 2003 6:56 am    Post subject: Reply with quote

Hi,

at least something is showing now. Unfortunately, the created image is completely black. The resizing and all works, however, it doesn't look like it's fully functioning. I already changed the functions back to GD 1.6 level.

Regards,

sderuiter
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 Nov 26, 2003 7:18 am    Post subject: Reply with quote

sderuiter wrote:
The resizing and all works, however, it doesn't look like it's fully functioning.


It's fully functional using GD 2+ Wink

I'll try to get an older version of GD installed later and try it out. However, not right now... Uncle's funeral to attend in a bit. I'll post up when I have anything to show.

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


Joined: 26 Nov 2003
Posts: 9

PostPosted: Wed Nov 26, 2003 7:29 am    Post subject: Reply with quote

FYI, attached code does work on my machine. I think it uses the same GD functions as the canvas script. I have a feeling i'm missing something here...

I wish you all the best at your uncle's funeral, and thank you for your time.

Regards,
sderuiter



Code:
function rectthumb ($src, $squaresize) { 
     
    if (!function_exists ("imagecreate") || !function_exists ("imagecreatetruecolor")) { 
        ErrorImage ("No image create functions!"); 
    } 

    $size = @getimagesize ($src); 
    if (!$size) { 
        ErrorImage ("Image File Not Found!"); 
    } else { 

            $newx = $squaresize;
            $newy = $squaresize;
            $ixstart = floor($size[0] / 2);
            $iystart = floor($size[1] / 2);       
       
        } 

    $destimg = imagecreate (240, 80 ); 

     if ($size[2]==2) { 
            $sourceimg = imagecreatefromjpeg ($src); 

     imagecopy ($destimg, $sourceimg, 0,0,$ixstart,$iystart, $ixstart+80, $iystart+240); 



     header ("content-type: image/jpeg"); 
     imagejpeg ($destimg); 
        } 
     else { 
            ErrorImage ("Image Type Not Handled!"); 
        } 
     

    imagedestroy ($destimg); 
    imagedestroy ($sourceimg); 

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 Nov 26, 2003 3:13 pm    Post subject: Reply with quote

sderuiter wrote:
FYI, attached code does work on my machine. I think it uses the same GD functions as the canvas script. I have a feeling i'm missing something here...


Hmm.. Not sure. Try the new version I just posted up (see other thread) and hopefully that might work for you.

sderuiter wrote:
I wish you all the best at your uncle's funeral, and thank you for your time.


Many thanks! It went better than expected, I must say.

Regards,

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


Joined: 26 Nov 2003
Posts: 9

PostPosted: Thu Nov 27, 2003 2:48 am    Post subject: Reply with quote

Thank you for the new version. I think it solves my problem, but only half of it. I'm running PHP in SAFE MODE (not my choice!) and the saveimage function doesn't work. I've sort of given up on safemodephpproblemsolving.

Fortunately, at home I have win2k+apache+newest release of PHP including gd2.0.8. I've installed your script there and it works like a charm. It's a roundabout way, but it will do. I'll create thumbnails locally and upload them to my server.

BTW, would you mind sharing with us the source of the canvascrop demo? THis is exactly what I had in mind, especially the radiobuttons for choosing the positions.

Thank you.
Regards,
sderuiter
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 Nov 27, 2003 4:20 am    Post subject: Reply with quote

sderuiter wrote:
BTW, would you mind sharing with us the source of the canvascrop demo? THis is exactly what I had in mind, especially the radiobuttons for choosing the positions.


Sure, why not?

It's split into two files:

index.php

PHP:
<?php

    
include "_header.php";
    echo 
'<h1 class="mainheader">Crop Canvas</h1><br>';

    if (!isset(
$_GET['show']))
    {
?>

<form action="" method="get">
Select cropping method<br><br>
<select name="show">
    <option value="cropBySize">crop by size</option>
    <option value="cropToSize">crop to size</option>
    <option value="cropByPercent">crop by percent</option>
    <option value="cropToPercent">crop to percent</option>
    <option value="cropToDimensions">crop to dimensions</option>
</select><br><br>
Select crop area<br><br>
<table border="0" cellpadding="5">
<tr>
    <td align="center" valign="middle"><input type="radio" name="position" value="0" checked></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="1"></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="2"></td>
</tr>
<tr>
    <td align="center" valign="middle"><input type="radio" name="position" value="3"></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="4"></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="5"></td>
</tr>
<tr>
    <td align="center" valign="middle"><input type="radio" name="position" value="6"></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="7"></td>
    <td align="center" valign="middle"><input type="radio" name="position" value="8"></td>
</tr>
</table>
<br><br>
<table border="0" cellpadding="5">
<tr>
    <td>size x<br>(px or %)</td>
    <td>size y<br>(px or %)</td>
    <td>end size x<br>(used only when cropping to a dimension)</td>
    <td>end size y<br>(used only when cropping to a dimension)</td>
</tr>
<tr>
    <td><input type="text" name="sx" size="5" value="83"></td>
    <td><input type="text" name="sy" size="5" value="98"></td>
    <td><input type="text" name="ex" size="5"></td>
    <td><input type="text" name="ey" size="5"></td>
</tr>
</table>
<br><br>
<?php

    $sizes 
GetImageSize('original.png');
    echo 
'Original image ('$sizes[3], ')';

?><br><br>
<img src="original.png">

<br><br>

<input type="submit" value="generate">
</form>


<?php
    
}
    else
    {
        echo 
'<img src="showimage.php?'$_SERVER['QUERY_STRING'], '">';
    }

    include 
"_footer.php";
?>


and showimage.php

PHP:
<?php

    
require 'class.cropcanvas.php';
    
$cc = new canvasCrop(true);
    
    
$cc->loadImage('original.png');

    switch(
$_GET['show'])
    {
        case 
"cropBySize":
            
$cc->cropBySize($_GET['sx'], $_GET['sy'], $_GET['position']);
            break;
        case 
"cropToSize":
            
$cc->cropToSize($_GET['sx'], $_GET['sy'], $_GET['position']);
            break;
        case 
"cropByPercent":
            
$cc->cropByPercent($_GET['sx'], $_GET['sy'], $_GET['position']);
            break;
        case 
"cropToPercent":
            
$cc->cropToPercent($_GET['sx'], $_GET['sy'], $_GET['position']);
            break;
        case 
"cropToDimensions":
            
$cc->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey'], $_GET['position']);
            break;
    }

    
$cc->showImage('jpg'100);
    
$cc->flushImages();    

?>


Probably not the most elegant of solutions - but it was just a demo file... Wink

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