TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Installing GD (http://www.talkphp.com/general/1366-installing-gd.html)

Tanax 10-31-2007 05:12 PM

Installing GD
 
Hi, I'm wondering why I get this error.

I'm using a thumbnail class, and it requires GD.
I've checked my php.ini and it's already including the php_gd2.dll extention, and I've checked that it exists in the extention folder.

So why doesn't it work? :S

I use WAMP btw.

Salathe 10-31-2007 05:21 PM

What is the exact error that you're getting? Check with phpinfo() that the GD module has (or hasn't) been loaded.

Tanax 10-31-2007 05:25 PM

Quote:

Additional Modules
Module Name

Environment
Nope,hasn't been loaded :S:S

Actually it said this:
Quote:

Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Says gd something.. :P


Anyways, I've gotten this error:
Quote:

You do not have the GD Library installed. This class requires the GD library to function properly. visit http://us2.php.net/manual/en/ref.image.php for more information

Wildhoney 10-31-2007 05:48 PM

Are the extensions in php.ini pointing to the correct location?
Are you editing the correct php.ini file? (For me: C:\wamp\Apache2\bin)

Tanax 10-31-2007 05:53 PM

php.ini(in C:\wamp\Apache2\bin)
Quote:

;extension=php_gd2.dll
same place, same file:
Quote:

extension_dir = "c:/wamp/php/ext/"
It.. seems to be correct :S

Tanax 10-31-2007 06:00 PM

Btw, this is the thing that is giving the errormsg:

PHP Code:

if(!function_exists("gd_info")) {
            echo 
'You do not have the GD Library installed.  This class requires the GD library to function properly.' "\n";
            echo 
'visit http://us2.php.net/manual/en/ref.image.php for more information';
            exit;
        } 


Salathe 10-31-2007 06:02 PM

Remove the semicolon from the beginning of that line in your php.ini.

Tanax 10-31-2007 06:35 PM

Okey! It's working now :D

But now I got this:
Quote:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1600 bytes) in C:\wamp\www\Gallery Class\class\thumbnail.inc.php on line 152
line 151,152,153:
PHP Code:

                case 'JPG':
                    
$this->oldImage ImageCreateFromJpeg($this->fileName);
                    break; 


Wildhoney 10-31-2007 06:55 PM

Your JPEG will be too large, no doubt. Or you may be stuck in a loop.

Tanax 10-31-2007 07:35 PM

Yea but isn't there any way to remove the limit?
Cause some of the images that I need to resize is 4mb-7mb, and that's why I need to resize them, cause they're 2000+ px in width, takes ALOT of time to load!!

Salathe 10-31-2007 08:16 PM

Your current memory (RAM) limit is set to 8MB, you can change the limit using the memory_limit in your php.ini file. Set it to "numberM", for example 50M would be 50 Megabytes of RAM.

Tanax 10-31-2007 08:23 PM

Ah, I found it ;)

Thanks :D

Tanax 10-31-2007 08:53 PM

Okey, so I had to change this to 120M to be able to view those images.

A simple question, if I were to put up this script on a webhotel, would this be sucking alot of bandwidth?

And if it does, would it be better if I were to simply load all the 2000px in width-pictures with no resizing?

bluesaga 11-01-2007 09:18 AM

It would not use much bandwidth, but it would be a killer for server resources if needed to be run on the fly... all the time!

How large are the images? 120Mb seems huge, but is definitely plausable.

The program isn't storing large amounts of files in arrays is it?

Tanax 11-01-2007 12:17 PM

Okey, the images are around 5-7mb each.

I use this script:
http://www.gen-x-design.com/projects...bnailer-class/

Together with an own gallery class. It doesn't store files in an array, it just prints the images out.. eh, you can view the gallery here(without thumbnail script):

www.cumulustidning.se/bildbank/index.php

It's in swe though, but I think you can find your way around..

bluesaga 11-01-2007 01:00 PM

5-7mb would imply 5-7mb of memory used to manipulate the images. Thus you shouldn't need 120mb of memory available!

Sounds like some bad variable usage if your using that much memory.

Salathe 11-01-2007 01:31 PM

This class comes in both PHP 4 and 5 flavors, but I highly recommend the PHP 5 version, due to the “__destruct()” function that became available in version 5. This helps ensure that you do not inadvertently create memory leaks by forgetting to call the “destruct()” function explicitly, like you must in the PHP 4 version of this script.
If you're using PHP4, are you explicitly calling the destruct method?

Tanax 11-01-2007 02:17 PM

Oh, no I haven't called it.. I'll change it and come back to you asap.

Thanks

Tanax 11-01-2007 02:34 PM

Nope it still uses 120.. :S

bluesaga 11-01-2007 05:12 PM

Ok please:

1) Add
PHP Code:


<?php
if( !function_exists('memory_get_usage') )
{
    function 
memory_get_usage()
    {
        
//If its Windows
        //Tested on Win XP Pro SP2. Should work on Win 2003 Server too
        //Doesn't work for 2000
        //If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
        
if ( substr(PHP_OS,0,3) == 'WIN')
        {
               if ( 
substrPHP_OS0) == 'WIN' )
                {
                    
$output = array();
                    
exec'tasklist /FI "PID eq ' getmypid() . '" /FO LIST'$output );
       
                    return 
preg_replace'/[\D]/'''$output[5] ) * 1024;
                }
        }else
        {
            
//We now assume the OS is UNIX
            //Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
            //This should work on most UNIX systems
            
$pid getmypid();
            
exec("ps -eo%mem,rss,pid | grep $pid"$output);
            
$output explode("  "$output[0]);
            
//rss is given in 1024 byte units
            
return $output[1] * 1024;
        }
    }
}
?>

To the top of your code, either in an include or at the very top (the IF statement requires that it is at the top)....

2) Before and After every image resize, use the function above and echo the output of it. This should give an indicator of where the problems within your script are.

Note: I mean the script you are using to run the class that resizes the image.


All times are GMT. The time now is 08:34 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0