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.


php & gd requirements

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


Joined: 12 Nov 2003
Posts: 1

PostPosted: Wed Nov 12, 2003 6:46 am    Post subject: php & gd requirements Reply with quote

Hi Andy,

Thanks for this great feature !

I was wondering about the requirements to use it.

I'm running php 4.2.x and with php_gd.dll extension installed (i.e. gd 1.6.2), I cannot get Crop Canvas to work. I get : Error in function showImage: There is no processed image to show..

With php_gd2.dll installed (i.e. gd 2.0), cropToDimensions function is working fine.

For maintenance problems, I still wish to use gd 1.6 though. Any chance to have cropToDimensions working with it ?

Thanks,

Alain
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 12, 2003 10:53 am    Post subject: Reply with quote

Hi Alain,

Welcome to the board!

It's not actually the 'cropToDomensions' function that wont work, but the internal '_cropSize' function. this is because there are two GD2 function calls in there:

PHP:
<?php
        
// ...
        
$this->_imgFinal = @ImageCreateTrueColor($nx$ny);
        if (
$ox == -|| $oy == -1)
        {
            list(
$ox$oy) = $this->_getCopyPosition($nx$ny$position);
        }
        @
ImageCopyResampled($this->_imgFinal$this->_imgOrig00$ox$oy$nx$ny$nx$ny);
        
// ...
?>


The functions there are:

ImageCreateTrueColor
ImageCopyResampled

What you could try is to simply replace those with their GD1 counterparts:

ImageCreate
ImageCopy

That should be all you need to do (off the top of my head). Try it out and let us know how 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
amnuts
Site Admin


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

PostPosted: Fri Nov 28, 2003 7:48 am    Post subject: Reply with quote

Hi,

In follow-up to this; check out the new version of the class. It takes into account what version of GD you have and will use the appropriate functions.

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


Joined: 24 Mar 2004
Posts: 2

PostPosted: Wed Mar 24, 2004 9:31 pm    Post subject: Reply with quote

Andy this code did not work for me:

PHP:
<?php $this->_gdVersion = (function_exists('imagecreatetruecolor')) ? 1?>


Strangely it gives version 2, but the ImageCreateTrueColor function brings up the error "Warning: imagecreatetruecolor(): requires GD 2.0 or later". My phpinfo() says I have gd version 1.6.2 or higher. I got the crop tool to work by commenting out the gd2 functions.
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 Mar 25, 2004 3:56 am    Post subject: Reply with quote

Hi bbarker, and welcome to the board.

There is another function in the crop canvas class that you can use to determine the GD version. It does this by parsing the phpinfo output.

Replace:

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


with:

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


and it should work out for you.

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


Joined: 24 Mar 2004
Posts: 2

PostPosted: Thu Mar 25, 2004 8:00 pm    Post subject: Reply with quote

Thanks, it worked!
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