Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 512635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:20:24+00:00 2026-05-13T07:20:24+00:00

I’ve got the following function that generates and saves an image based a text

  • 0

I’ve got the following function that generates and saves an image based a text parameter. How can I call this in my file? I tried

INCLUDE 'outPrice.php'; 

to link to the external PHP and called it with this command,

outPrice($text);

To which I got the following response.

Warning: Cannot modify header information - headers already sent 

Any help would be appreciated.

function outPrice($textval){
    $textcolor = '666666';


    $font="bgtbt.ttf";
    $size = 20;
    $padding= 1;
    $bgcolor= "ffffff";

    $transparent = 0;
    $antialias = 0;

    $fontfile = $fontpath.$font;

    $box= imageftbbox( $size, 0, $fontfile, $textval, array());
    $boxwidth= $box[4];
    $boxheight= abs($box[3]) + abs($box[5]);
    $width= $boxwidth + ($padding*2) + 1;
    $height= $boxheight + ($padding) + 0;
    $textx= $padding;
    $texty= ($boxheight - abs($box[3])) + $padding;

    // create the image
    $png= imagecreate($width, $height);


    $color = str_replace("#","",$bgcolor);
    $red = hexdec(substr($bgcolor,0,2));
    $green = hexdec(substr($bgcolor,2,2));
    $blue = hexdec(substr($bgcolor,4,2));
    $bg = imagecolorallocate($png, $red, $green, $blue);

    $color = str_replace("#","",$textcolor);
    $red = hexdec(substr($textcolor,0,2));
    $green = hexdec(substr($textcolor,2,2));
    $blue = hexdec(substr($textcolor,4,2));
    $tx = imagecolorallocate($png, $red, $green, $blue);


    imagettftext( $png, $size, 0, $textx, $texty, $tx, $fontfile, $textval );

    header("content-type: image/jpeg");
    imagejpeg($png, "price".$textval.".jpg");
    imagedestroy($png);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:20:24+00:00Added an answer on May 13, 2026 at 7:20 am

    How are you invoking this file? If you are calling it inside of an <img> tag, or from a CSS directive, then do as C. Walsh says and check for whitespace in the file (tip: for binary data, don’t include a closing ?> tag in your script) as well as a Byte Order Mark at the beginning of your file (use a HEX editor like PSPad for this).

    You may also want to consider, since errors may occur during your image script’s execution, wrapping the script contents in ob_start() and ob_end_clean(), where ob_end_clean() is called just before the headers are sent and the image is generated.

    If you are invoking it directly from the file in which you wish to embed the image, then use the following HTML scheme:

    <img src="data:image/png;base64,DATADATADATA" alt ="" />
    

    Where DATADATADATA is the base64 encoded version of your image.

    See:

    1. Data URI Scheme
    2. PHP Manual Entry for base64_encode()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 270k
  • Answers 270k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer With that code (and especially your very novel "while true"… May 13, 2026 at 1:26 pm
  • Editorial Team
    Editorial Team added an answer The advantage is already described in the very same Sun… May 13, 2026 at 1:26 pm
  • Editorial Team
    Editorial Team added an answer Why not just use toggle? $("#show-background").click(function () { $("#content-area").animate({opacity: 'toggle'},… May 13, 2026 at 1:26 pm

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.