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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to convert a dynamic php image into a simple png.

    Hi guys,

    I want to convert my dynamic img:
    http://hyip-status.com/monitor/img.php?id=181

    Into a simple dynamic png which will be held here:
    http://hyip-status.com/monitor/img/181.png

    PHP Code:
    <?php
    $img
    =imagecreatefrompng('gfx/banner.png');
    if(
    strlen($_GET['id']))
        {
        include(
    './config/config.php');
        
    $id=$_GET['id'];
        if(
    $result=mysql_unbuffered_query("SELECT * FROM `payouts` WHERE `id_program`='$id' ORDER BY `data` DESC, `id_payout` DESC"))
                {
                
    $i=0;
                
    $inv=0;
                
    $pay=0;
                while(
    $row=mysql_fetch_assoc($result))
                            {
                               if (
    $row['status']==0)
                                 
    $inv $inv $row['kwota'];
                               else
                                  
    $pay $pay $row['kwota'];
                            }
                }
        
    $table "programs";    
        if(
    $result=mysql_query("SELECT `nazwa`, `rating`, `status`,`premium`,`total`,`risk`,`data` FROM `programs` WHERE `id_program`='"$_GET['id'] ."' AND `blacklist`=''") and $payout=mysql_query("SELECT `data` FROM `payouts` WHERE `id_program`='"$_GET['id'] ."' AND `status`!='0' ORDER BY `data` DESC LIMIT 1"))
            {
            if(
    mysql_num_rows($result)==1)
                {
                
    $inv='Investment: $'.$inv.'';
                
    $pay='Returns: $'.$pay.'';
                
    $date=date("F j, Y");
                
    $monitored=mysql_result($result06);
                
    $name=mysql_result($result00);
                
    $rating=('User Rate: '.mysql_result($result01));
                
    $status=mysql_result($result02);
                
    $type=mysql_result($result03);
                
    $ratio='Payout Ratio: '.mysql_result($result04).'%';
                
    $risk=mysql_result($result05);
                
    //Finding Monitored days.
                 // Convert each of them into strings
                
    $date2 date("Y-m-d"); 
                
    $string1 strtotime($monitored); // or the variable $date1
                
    $string2 strtotime($date2); // or the variable $date2

                // Subtract the difference
                
    $difference $string2-$string1;

                
    // divide by the time period you wish to check

                
    $DifferenceInDays = ($difference/86400);
                
    settype($DifferenceInDays"string");
                
    $test '0'.strstr($DifferenceInDays".");
                
    settype($test"float");
                If (
    $test 0){
                    
    settype($DifferenceInDays"float");
                    
    $DifferenceInDays=$DifferenceInDays-$test;
                    }
                
    $MonitoredFor 'Monitored: '.$DifferenceInDays.' Days';
                
    //END MONITORED DAYS
                
    if(mysql_num_rows($payout)==1){
                    
    $last_payout=mysql_result($payout00);                
                    if (
    $last_payout==date("Y-m-d"))
                        {
                          
    $last_payout='Today';
                        }
                    }
                else
                    
    $last_payout='No Payouts';

                if(
    $type=='*')
                        
    $type='Type: Premium';
                else
                        
    $type='Type: Normal';
                
    mysql_free_result($result);
                
    $img=imagecreatefrompng('gfx/banner.png');
                
    $white=imagecolorallocate($img255255255);
                
    $green=imagecolorallocate($img2322123);
                
    $name=((strlen($name)>15) ? substr($name013). '...' $name);
                
    $x floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($name)) / 2));
                
    $datealign floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($date)) / 2));
                
    $ratingalign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($rating)) / 2));
                
    $typealign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($type)) / 2));
                
    $invalign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($inv)) / 2));
                
    $payalign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($pay)) / 2));
                
    $ratioalign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($ratio)) / 2));
                
    $lpayalign floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($last_payout)) / 2));
                
    $monitoredalign floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($MonitoredFor)) / 2)); 
                
    imagestring($img3$x64$name$white);
                
    imagestring($img3$datealign103$date$black);
                
    imagestring($img2$monitoredalign117$MonitoredFor$black);
                
    imagestring($img2$typealign129$type$black);
                
    imagestring($img2$ratingalign140$rating$black);
                
    imagestring($img2$invalign152$inv$black);
                
    imagestring($img2$payalign164$pay$black);
                
    imagestring($img2$ratioalign176$ratio$black);
                
    imagestring($img224189'Last Payout:'$black);
                
    imagestring($img3$lpayalign202$last_payout$lpaycolor);
                if (
    $p=imagecreatefromgif('./gfx/icons/status_'$status .'.gif'))
                    {
                    
    imagecopyresampled($img$p584001101611016);
                    
    imagedestroy($p);
                    }
                if (
    $g=imagecreatefromgif('./gfx/icons/risk_'$risk .'.gif'))
                    {
                    
    imagecopyresampled($img$g362220047154715);
                    
    imagedestroy($g);
                    }
            }
        else
           {}
        }
    }
    header("Content-type: image/png");
    imagepng($img);
    ?>
    Is there anyway to do this?

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    createDynamicPNG.php
    Code:
    <?php
    $outputFile = "image.png";
    $filename = "dynamicImage.php";
    $contents = file_get_contents($filename);
    $handle = fopen($outputFile,"w");
    fwrite($handle, $contents);
    fclose($handle);
    ?>
    dynamicImage.php
    Code:
    <?php
    $img=imagecreatefrompng('gfx/banner.png');
    if(strlen($_GET['id']))
        {
        include('./config/config.php');
        $id=$_GET['id'];
        if($result=mysql_unbuffered_query("SELECT * FROM `payouts` WHERE `id_program`='$id' ORDER BY `data` DESC, `id_payout` DESC"))
                {
                $i=0;
                $inv=0;
                $pay=0;
                while($row=mysql_fetch_assoc($result))
                            {
                               if ($row['status']==0)
                                 $inv = $inv + $row['kwota'];
                               else
                                  $pay = $pay + $row['kwota'];
                            }
                }
        $table = "programs";    
        if($result=mysql_query("SELECT `nazwa`, `rating`, `status`,`premium`,`total`,`risk`,`data` FROM `programs` WHERE `id_program`='". $_GET['id'] ."' AND `blacklist`=''") and $payout=mysql_query("SELECT `data` FROM `payouts` WHERE `id_program`='". $_GET['id'] ."' AND `status`!='0' ORDER BY `data` DESC LIMIT 1"))
            {
            if(mysql_num_rows($result)==1)
                {
                $inv='Investment: $'.$inv.'';
                $pay='Returns: $'.$pay.'';
                $date=date("F j, Y");
                $monitored=mysql_result($result, 0, 6);
                $name=mysql_result($result, 0, 0);
                $rating=('User Rate: '.mysql_result($result, 0, 1));
                $status=mysql_result($result, 0, 2);
                $type=mysql_result($result, 0, 3);
                $ratio='Payout Ratio: '.mysql_result($result, 0, 4).'%';
                $risk=mysql_result($result, 0, 5);
                //Finding Monitored days.
                 // Convert each of them into strings
                $date2 = date("Y-m-d"); 
                $string1 = strtotime($monitored); // or the variable $date1
                $string2 = strtotime($date2); // or the variable $date2
    
                // Subtract the difference
                $difference = $string2-$string1;
    
                // divide by the time period you wish to check
    
                $DifferenceInDays = ($difference/86400);
                settype($DifferenceInDays, "string");
                $test = '0'.strstr($DifferenceInDays, ".");
                settype($test, "float");
                If ($test > 0){
                    settype($DifferenceInDays, "float");
                    $DifferenceInDays=$DifferenceInDays-$test;
                    }
                $MonitoredFor = 'Monitored: '.$DifferenceInDays.' Days';
                //END MONITORED DAYS
                if(mysql_num_rows($payout)==1){
                    $last_payout=mysql_result($payout, 0, 0);                
                    if ($last_payout==date("Y-m-d"))
                        {
                          $last_payout='Today';
                        }
                    }
                else
                    $last_payout='No Payouts';
    
                if($type=='*')
                        $type='Type: Premium';
                else
                        $type='Type: Normal';
                mysql_free_result($result);
                $img=imagecreatefrompng('gfx/banner.png');
                $white=imagecolorallocate($img, 255, 255, 255);
                $green=imagecolorallocate($img, 23, 221, 23);
                $name=((strlen($name)>15) ? substr($name, 0, 13). '...' : $name);
                $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($name)) / 2));
                $datealign = floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($date)) / 2));
                $ratingalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($rating)) / 2));
                $typealign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($type)) / 2));
                $invalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($inv)) / 2));
                $payalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($pay)) / 2));
                $ratioalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($ratio)) / 2));
                $lpayalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(3) * strlen($last_payout)) / 2));
                $monitoredalign = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($MonitoredFor)) / 2)); 
                imagestring($img, 3, $x, 64, $name, $white);
                imagestring($img, 3, $datealign, 103, $date, $black);
                imagestring($img, 2, $monitoredalign, 117, $MonitoredFor, $black);
                imagestring($img, 2, $typealign, 129, $type, $black);
                imagestring($img, 2, $ratingalign, 140, $rating, $black);
                imagestring($img, 2, $invalign, 152, $inv, $black);
                imagestring($img, 2, $payalign, 164, $pay, $black);
                imagestring($img, 2, $ratioalign, 176, $ratio, $black);
                imagestring($img, 2, 24, 189, 'Last Payout:', $black);
                imagestring($img, 3, $lpayalign, 202, $last_payout, $lpaycolor);
                if ($p=imagecreatefromgif('./gfx/icons/status_'. $status .'.gif'))
                    {
                    imagecopyresampled($img, $p, 5, 84, 0, 0, 110, 16, 110, 16);
                    imagedestroy($p);
                    }
                if ($g=imagecreatefromgif('./gfx/icons/risk_'. $risk .'.gif'))
                    {
                    imagecopyresampled($img, $g, 36, 222, 0, 0, 47, 15, 47, 15);
                    imagedestroy($g);
                    }
            }
        else
           {}
        }
    }
    header("Content-type: image/png");
    imagepng($img);
    ?>
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  

    Posting Permissions

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