Results 1 to 8 of 8

Thread: No generated image nomore

  1. #1
    Join Date
    Jan 2016
    Posts
    23
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default No generated image nomore

    Im still working at fixing a website code after the server was upgraded. This no longer works. Any help from anyone?

    PHP Code:
    $width 250// width of bar
    $height 25// height of bar

    $per imagecreate($width$height);
    $background imagecolorallocate($per0xFF0xFF0xFF);
    $foreground imagecolorallocate($per0x000x8A0x01);
    $border imagecolorallocate($per0x990x990x99);
    if (
    $_GET['per'] > 0){
        
    $grad imagecreatefrompng("bar.png");
        
    $per2 imagecopy($per$grad1100, ($_GET['per']*$width/100), ($height-2));
        
    imagerectangle($per00, ($width-1), ($height-1), $border);
        }
    header("Content-type: image/png");
    imagepng($perNULL, ($height-2)); 
    Last edited by Beverleyh; 01-29-2016 at 08:15 AM. Reason: formatting

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Hmmm, the code looks incomplete. For example, the $background and $foreground variables don't look like they're ever used (in this snippet).

    Is this *all* the script? And are you able to elaborate on "This no longer works" - are you getting errors on screen to say what isn't working?
    Last edited by Beverleyh; 01-29-2016 at 08:12 AM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    bojangles (01-29-2016)

  4. #3
    Join Date
    Jan 2016
    Posts
    23
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default

    Thanks for replying Bev. I couldn't tell you what the variables are. Having looked through the script (and this is very almost everything except for the img below) I can't tell where they are used. All I know is that the image used to be generated but after the server upgrade it no longer is.

    It is visible in an img <img src="image.php?per=77">

    The "per" part of the src makes the bar image longer but now all it does is show as broken. No image generated nomore.

  5. #4
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Try adding a few debugging statements to find out where it's going wrong:

    PHP Code:
    $width 250// width of bar
    $height 25// height of bar

    $per imagecreate($width$height) or die("Cannot initialise image stream.");
    $background imagecolorallocate($per0xFF0xFF0xFF) or die("Cannot add background colour.");
    $foreground imagecolorallocate($per0x000x8A0x01) or die("Cannot add foreground colour.");
    $border imagecolorallocate($per0x990x990x99) or die("Cannot add border colour.");
    if (
    $_GET['per'] > 0){
        
    $grad imagecreatefrompng("bar.png");
        
    $per2 imagecopy($per$grad1100, ($_GET['per']*$width/100), ($height-2));
        
    imagerectangle($per00, ($width-1), ($height-1), $border);
        }
    header("Content-type: image/png");
    imagepng($perNULL, ($height-2)); 

  6. #5
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    ... an afterthought. You said it's happened as a result of a server upgrade. Have you ensured that the GD library is enabled in your php.ini file?

  7. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I'm tempted to say that this line is the problem;
    Code:
    imagepng($per, NULL, ($height-2));
    The last parameter - where you have ($height-2) - was introduced in PHP 5.1.2. It is a quality setting from 0-9 or -1, so your ($height-2) is likely causing it to fail because the result falls outside the allowed values. I'm not sure why that's in there but I'm guessing that your server has upgraded from PHP4 where the quality parameter was just being ignored, regardless of whatever value was being calculated.

    Try changing it to this (6 is default quality) to see if it helps
    Code:
    imagepng($per, NULL, 6);
    OR try omitting the quality parameter setting altogether;
    Code:
    imagepng($per, NULL);
    Let me know how it goes.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  8. The Following User Says Thank You to Beverleyh For This Useful Post:

    bojangles (01-29-2016)

  9. #7
    Join Date
    Jan 2016
    Posts
    23
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default

    Bev has got me covered yet again! You got it in one and your suggestion has completely solved the issue. My image is back where it was

    Amazingly helpful as always! Thank you.

  10. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Brilliant. Happy to help
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  11. The Following User Says Thank You to Beverleyh For This Useful Post:

    bojangles (01-29-2016)

Similar Threads

  1. Resolved [ask] code generated
    By madkixt in forum JavaScript
    Replies: 8
    Last Post: 11-24-2008, 10:54 AM
  2. php generated xml vs hand typed
    By rd42 in forum Flash
    Replies: 3
    Last Post: 10-31-2008, 11:17 PM
  3. CSS ignored by FF in PHP generated page
    By Strangeplant in forum CSS
    Replies: 1
    Last Post: 04-06-2008, 12:04 AM
  4. Generated IFrame Transparency
    By phb5000 in forum JavaScript
    Replies: 7
    Last Post: 04-08-2007, 11:20 PM
  5. CSS Styling A PHP Generated Table
    By tomyknoker in forum PHP
    Replies: 4
    Last Post: 04-04-2007, 02:24 PM

Bookmarks

Posting Permissions

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