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 3 of 3
  1. #1
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts

    Exclamation Question about imagepng()

    So I have a html form which takes values and places them on an image using coordinates and the imagepng() function. Everything works fine after the user submits the form. But i'm trying to add a print button on the page but every time I try to add buttons I get header errors, I tried adding the php to the body, and putting the html before and after the php, and I cant get anything to work. So, I was wondering if theres something I need to do to the image before I can add other content to the page.

    Any ideas?

    If it helps:

    Code:
    <?php
    
    $font_size = 10;
    $font_file = 'calibri.ttf';
    $image_front = 'http://imgur.com/OeRqF.jpg';
    $image =  imagecreatefromjpeg($image_front);
    $font_color = imagecolorallocate($image, 23, 50, 115);
    
    //Date
    imagettftext($image, $font_size, 0, 80, 270, $font_color, $font_file, $_POST['date']);
    //Name
    imagettftext($image, $font_size, 0, 210, 270, $font_color, $font_file, $_POST['name']);
    
    //Certification
    $x = 'X';
    $x2 = 'x';
    
    if($_POST['certification'] == 'cc'){
    	imagettftext($image, $font_size, 0, 436, 270, $font_color, $font_file, $x);
    }
    else if($_POST['certification'] == 'p'){
    	imagettftext($image, $font_size, 0, 510, 270, $font_color, $font_file, $x);
    }
    
    //EMT Number
    imagettftext($image, $font_size, 0, 90, 295, $font_color, $font_file, $_POST['emtnumber']);
    
    //Agency
    imagettftext($image, $font_size, 0, 240, 295, $font_color, $font_file, $_POST['agency']);
    
    //Type of CPAP Used
    imagettftext($image, $font_size, 0, 170, 320, $font_color, $font_file, $_POST['typecpap']);
    
    //Age
    imagettftext($image, $font_size, 0, 75, 380, $font_color, $font_file, $_POST['age']);
    
    //Gender
    if($_POST['gender'] == 'm'){
    	imagettftext($image, $font_size, 0, 130, 382, $font_color, $font_file, $x);
    }
    else if($_POST['gender'] == 'f'){
    	imagettftext($image, $font_size, 0, 185, 382, $font_color, $font_file, $x);
    }
    
    //Severity
    if($_POST['respdistress'] == 'moderate'){
    	imagettftext($image, $font_size, 0, 388, 382, $font_color, $font_file, $x);
    }
    else if($_POST['respdistress'] == 'severe'){
    	imagettftext($image, $font_size, 0, 463, 382, $font_color, $font_file, $x);
    }
    
    //Vitals 1
    imagettftext($image, $font_size, 0, 165, 425, $font_color, $font_file, $_POST['resp1']);
    imagettftext($image, $font_size, 0, 228, 425, $font_color, $font_file, $_POST['pulse1']);
    imagettftext($image, $font_size, 0, 278, 425, $font_color, $font_file, $_POST['systolic1']);
    imagettftext($image, $font_size, 0, 308, 425, $font_color, $font_file, $_POST['diastolic1']);
    imagettftext($image, $font_size, 0, 370, 425, $font_color, $font_file, $_POST['o2sat1']);
    imagettftext($image, $font_size, 0, 455, 425, $font_color, $font_file, $_POST['et1']);
    //ECG 1
    imagettftext($image, $font_size, 0, 130, 445, $font_color, $font_file, $_POST['ecg1']);
    
    //Vitals 2
    imagettftext($image, $font_size, 0, 165, 468, $font_color, $font_file, $_POST['resp2']);
    imagettftext($image, $font_size, 0, 228, 468, $font_color, $font_file, $_POST['pulse2']);
    imagettftext($image, $font_size, 0, 278, 468, $font_color, $font_file, $_POST['systolic2']);
    imagettftext($image, $font_size, 0, 308, 468, $font_color, $font_file, $_POST['diastolic2']);
    imagettftext($image, $font_size, 0, 412, 468, $font_color, $font_file, $_POST['o2sat2']);
    imagettftext($image, $font_size, 0, 490, 467, $font_color, $font_file, $_POST['et2']);
    //ECG 2
    imagettftext($image, $font_size, 0, 130, 489, $font_color, $font_file, $_POST['ecg2']);
    
    //CO2
    imagettftext($image, $font_size, 0, 362, 489, $font_color, $font_file, $_POST['co21']);
    imagettftext($image, $font_size, 0, 430, 489, $font_color, $font_file, $_POST['co22']);
    
    //Reason for CPAP use
    if($_POST['reason'] == 'PE'){
    	imagettftext($image, $font_size, 0, 86, 532, $font_color, $font_file, $x2);
    }
    else if($_POST['reason'] == 'other'){
    	imagettftext($image, $font_size, 0, 230, 532, $font_color, $font_file, $x2);
    }
    //Other Medical Control
    imagettftext($image, $font_size, 0, 345, 532, $font_color, $font_file, $_POST['othermedcontrol']);
    
    //Significant Effect
    if($_POST['feel'] == 'improved'){
    	imagettftext($image, $font_size, 0, 86, 575, $font_color, $font_file, $x2);
    }
    else if($_POST['feel'] == 'worsened'){
    	imagettftext($image, $font_size, 0, 158, 575, $font_color, $font_file, $x2);
    }
    else if($_POST['feel'] == 'none'){
    	imagettftext($image, $font_size, 0, 266, 575, $font_color, $font_file, $x2);
    }
    
    //Clinical Impression
    imagettftext($image, $font_size, 0, 250, 595, $font_color, $font_file, $_POST['impression']);
    
    //How long on CPAP
    imagettftext($image, $font_size, 0, 322, 616, $font_color, $font_file, $_POST['howlong']);
    
    //Complications
    if($_POST['complications'] == 'yes'){
    	imagettftext($image, $font_size, 0, 339, 638, $font_color, $font_file, $x2);
    }
    else if($_POST['complications'] == 'no'){
    	imagettftext($image, $font_size, 0, 398, 638, $font_color, $font_file, $x2);
    }
    
    //What/Why
    imagettftext($image, $font_size, 0, 100, 658, $font_color, $font_file, $_POST['whatwhy']);
    
    //Care without CPAP
    if($_POST['lastquestion'] == 'intubation'){
    	imagettftext($image, $font_size, 0, 178, 705, $font_color, $font_file, $x2);
    }
    else if($_POST['lastquestion'] == 'bvm'){
    	imagettftext($image, $font_size, 0, 286, 705, $font_color, $font_file, $x2);
    }
    else if($_POST['lastquestion'] == 'nrb'){
    	imagettftext($image, $font_size, 0, 358, 705, $font_color, $font_file, $x2);
    }
    
    //Date stamp
    $d = date("m-d-Y, h:i A");
    
    //Make image, store it in forms folder with date extension
    Header("Content-type: image/png");
    imagepng($image);
    imagepng($image,'forms/audit' . '_' . $d . '.png');
    
    //Make file to hold count for temp images
    $fp = fopen("form.txt", "r"); 
    $count = fread($fp, 1024); 
    fclose($fp); 
    $count = $count + 1; 
    $fp = fopen("form.txt", "w"); 
    fwrite($fp, $count); 
    
    //Make temp images for emailing
    imagepng($image,'forms/temp/audit_temp' . $count . '.png');
    fclose($fp); 
    
    //Kill resources
    imagedestroy($image); 
    ?>
    Go easy, i'm not exactly the greatest web programmer.

    Thanks for any help.

    - Anthony

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    That is because you are sending a header with that image. It would be better to redirect to some page and then use the image tag with the src being the generated image. Now the page you redirected to is just a simple html page which you can put buttons on.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Rappa (02-19-2010)

  • #3
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts
    Example, possibly?


  •  

    Posting Permissions

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