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

  • SEARCH
  • Home
  • 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 6134267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:20:01+00:00 2026-05-23T17:20:01+00:00

How can i generate multiple texts using the imagecreatetruecolor() method? I have the following

  • 0

How can i generate multiple texts using the imagecreatetruecolor() method? I have the following code, but this displays either the first font or the second – not both:

<?php
    // Set the content-type
     header('Content-type: image/png');


    // The text to draw
    $text = 'Hello Farooqi';
    $x = 0;
    $y = 0;
    $w = 50;
    $h = 50;
    $s = 13;


    // Create the image


      $im = imagecreatetruecolor($w , $s);
     imagesavealpha($im, true);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $black = imagecolorallocate($im,0,0,0);
    $text_color = imagecolorallocate($im, 200,200, 91);
    $blue  = imagecolorallocate($im,0,0,180);
    $alpha = imagecolorallocatealpha($im, 0, 0, 0, 127);

    //imagefilledrectangle($im, 0, 0, 150, 25, $black);

    imagefill($im, 0, 0, $alpha);


    // Replace path by your own font path
    $font = 'Calibri Bold.ttf';

    // Add the text
    $dimensions = imagettftext($im, $s, 0, $x, $y, $black, $font, $text);
    $textWidth = ($dimensions[2]);


     $imm = imagecreatetruecolor($w , $s);
     imagesavealpha($imm, true);

     $bluem  = imagecolorallocate($imm,50,50,50);
     $alpham = imagecolorallocatealpha($imm, 0, 0, 0, 127);

     imagefill($imm, 0, 0, $alpham);
    imagettftext($imm, $s, 0, $x+3, $y+3, $bluem, $font, $text);


    // Using imagepng() results in clearer text compared with imagejpeg()

    imagepng($im);
    imagepng($imm);
    imagedestroy($im);
    imagedestroy($imm);

    ?>

Here above in these last 4 lines only one line appears, and that’s the first one. How can I have both lines?

Please help. Thanks in advance.

  • 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-23T17:20:02+00:00Added an answer on May 23, 2026 at 5:20 pm

    The imagepng($im); will be called and outputted to your HTML code and as the header is set to an image it will display this image. No matter your imagepng($inm) that comes afterwards.

    A better way would be to create two different PHP files. One that does your script and ends in imagepng($im); and another one that ends in imagepng($inm);

    And then in your master PHP (header = text/html) file you just mention these 2 files in your image source:

    <img src="functions/first_image.php" />
    
    <img src="functions/second_image.php" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HQL query that can generate either an IList of results, or
I'm using a php loop to generate multiple button elements. How can I determine
Is there a tool that can generate sequence diagrams from running .NET code?
How can i generate bytecode (Byte[]) from a String at runtime, without using a
I'm using ElementTree to generate some HTML, but I've run into the problem that
I have multiple <body> tags from an word document. I do this with the
I have multiple buttons in gridview. How can i determine which particular button on
I'm attempting to run TextTransform.exe to generate code using a T4 template file. The
In Clearcase I can generate a label for a given set of files and
I'm looking for a tool which can generate a Makefile for a C/C++ project

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.