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.


ccCENTER doesnt work it does a ccTOPLEFT instead!!

 
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
Richard M
Newbie


Joined: 08 Jan 2004
Posts: 2

PostPosted: Thu Jan 08, 2004 1:14 pm    Post subject: ccCENTER doesnt work it does a ccTOPLEFT instead!! Reply with quote

I made the following script and it works fine on my computer but not on the serveur of my provider. There ccCENTER doesnt work it does a ccTOPLEFT instead !!!

require 'class.cropcanvas.php';

function crop($maison){
$imagefilename = '../photos/ML' . $maison . '-1.jpg';
$croppedimage = '../photos/CR' . $maison . '.jpg';
if (file_exists($croppedimage)==False) {
list($width, $height, $type, $attr) = getimagesize($imagefilename);
$cc = new canvasCrop(True);
$cc->loadImage($imagefilename);
if ($height<190) {
$newwidth=round((300/190)*$height);
$cc->cropToSize($newwidth, $height, ccCENTER); );
} else {
$cc->cropToSize(300, 190, ccCENTER); );
}
$cc->saveImage($croppedimage,80);
$cc->flushImages();
}
return $croppedimage;
}


I can not figure out what is going wrong. Any Ideas ?


Richard M.
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 Jan 08, 2004 3:00 pm    Post subject: Reply with quote

Hi, and welcome to the board!

Hmm.. Not too sure why that's not working for you (other than a couple extra ');' in there that shouldn't be). I plonked it into a test file (with just a little tweak) and it worked just fine:

PHP:
<?php

require 'class.cropcanvas.php';

function 
crop($maison) {
    
$imagefilename "./images/ML{$maison}-1.jpg";
    
$croppedimage "./images/CR{$maison}.jpg";
    if (
file_exists($croppedimage)==False) {
        list(
$width$height$type$attr) = getimagesize($imagefilename);
        
$cc = new canvasCrop(True);
        
$cc->loadImage($imagefilename);
        if (
$height<190) {
            
$newwidth=round((300/190)*$height);
            
$cc->cropToSize($newwidth$heightccCENTER);
        } else {
            
$cc->cropToSize(300190ccCENTER);
        }
        
$cc->saveImage($croppedimage,80);
        
$cc->flushImages();
    }
    return 
$croppedimage;
}

$foo crop('test');
echo 
$foo;

?>


So not sure... What server do you use and what does your provider use? Possibly there's some hints to be gained from knowing the PHP/GD versions and platform being used.

Sorry I can't be of more help right now!

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


Joined: 08 Jan 2004
Posts: 2

PostPosted: Fri Jan 09, 2004 4:10 am    Post subject: Reply with quote

Hi, here is some information...


My server (it works fine on this one)
EasyPhp 1.7
Php version : 4.3.3
Gd version : 2.0.15 Compatible

My provider server : www.online.fr
Php version : 4.3.1
Gd version : 2 or higher
link to provider phpinfo:
http://www.online.fr/support/fr/doc/php4/phpinfo.html


Hope this wil help...


Richard M.
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Mon Jan 12, 2004 4:49 am    Post subject: Reply with quote

Hmmm... A puzzler!

Okay, perhaps somewhere along the way the ccCENTRE/ccCENTER value is being changed? Unlikely, but you never know. Try echoing out the value around the same place that you're getting the failed crop. It should be the same value as defined in the top of the class.

Until I can think of anything else...

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


Joined: 25 Jun 2004
Posts: 1
Location: Bournemouth, UK

PostPosted: Fri Jun 25, 2004 12:16 pm    Post subject: I had this problem also... Reply with quote

Hi there,

I experienced this problem as well, so had a play around with the code.

In the _cropSize() function it decides whether to use ImageCopyResampled() or ImageCopyResized() - for me it was doing the first, and this was causing the problem...

Quote:
if ($this->_gdVersion == 2)
{
$this->_imgFinal = @ImageCreateTrueColor($nx, $ny);
@ImageCopyResampled($this->_imgFinal, $this->_imgOrig, 0, 0, $ox, $oy, $nx, $ny, $nx, $ny);
}
else
{
$this->_imgFinal = @ImageCreate($nx, $ny);
@ImageCopyResized($this->_imgFinal, $this->_imgOrig, 0, 0, $ox, $oy, $nx, $ny, $nx, $ny);
}


When I forced it to use ImageCopyResized(), it all worked fine for me!
So I guess it may be down to the version of PHP/GD and whether ImageCopyResampled() works correctly or not for you...

HTH,
Mr-lew
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 Jun 25, 2004 12:29 pm    Post subject: Reply with quote

Hi mr-lew, and welcome to the board!

Thanks for the reply to this thread - very interesting.

Just so people know; there is a check in the crop canvas class for gd which looks like this:

Code:
$this->_gdVersion = (function_exists('imagecreatetruecolor')) ? 2 : 1;


If you replace it with:

Code:
$this->_gdVersion = $this->_getGDVersion();


It will probably be a better check.

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