Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with GD for PHP

    hello, I am trying to get a small php script to run that generates a jpg however everytime i run it i receive an internal server error(500).

    I have tested it on 2 other servers and it runs fine, but on this one specific server it errs out. using php5 with gd2.0 compiled. any suggestions where the problem may be?
    PHP Code:
    <?php

    $ts_start_g 
    microtime(1);

    $a_photo_paths = array("DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG","DSC02275.JPG");

    $a_records = array();
    foreach(
    $a_photo_paths as $i => $s_path) {
    $ts_start microtime(1);
    $img_source imagecreatefromjpeg($s_path);
    $img_print imagecreatetruecolor(500375);
    imagecopyresampled($img_print$img_source000050037516321224);
    imagejpeg($img_print"resized/".$s_path85);
    $a_records[] = round(microtime(1) - $ts_start5)." -- ".$s_path;
    if(
    $i >= 9) break;
    }

    ?>

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    If the code works fine on other servers then the problem isnt in your code. Do you have any kind of support with your hosting?

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. What is it that they should be looking for to determine what is causing the issue? I know GD works on the server because I use it to generate captcha images with security codes and random letters/numbers in the image.

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    what I would do is just send them the script, explain that it works on other servers you've tried it on and ask why it doesnt work on their server and then what can they do to make it work - you are their customer after all.

  • #5
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    Not sure if this will help...but If GD is installed on that particular server, it could will be something to do with the amount of memory allocated.

    try adding the following at the top of page

    ini_set("memory_limit","30M");

  • #6
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    memory limit shouldnt cause an internal server error. It should just give you a nice little message saying you've exceeded the memory limit... then again that code shouldnt cause an internal server error either.

  • #7
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks everyone. the post about memory limit gave me an idea.


    it had to do with CPU time allowed to process the requests.

    currently there were 10 images in the array causing an internal server error. when I removed them and left 1 image in the array the script ran fine and returned:

    Process took 0.92 seconds.

    tried it with up to 9 images and all was good until the 10th image which exceeded 10 seconds of CPU time.

    so it appears as though host does not allow the script to process longer than roughly 10-12 seconds before causing an error


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •