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 231915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:58:23+00:00 2026-05-11T19:58:23+00:00

I want to create a small function in PHP which takes in arguments like

  • 0

I want to create a small function in PHP which takes in arguments like color, shape, transparency etc. and outputs a PNG image. I heard about PHP GD library but I want to know how can one create something as creative as soon.media.mit.edu

  • 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-11T19:58:23+00:00Added an answer on May 11, 2026 at 7:58 pm

    This is a good example, you can do virtually everything using these functions. While possible, creating an image like the one you described would be pretty hard by I have done some weird stuff with gradients, loops and colors though.

    If you wanted to make an image like that dynamically based on some parameters you can always create the images beforehand in photoshop and then overlay them based on what a user selects.

    There is a lot of fun you can have.

    Edit: Oh by the way, if your interested giving an invalid parameter shows some of the python code that is responsible for creating the image and causing the error. It would be a good place to get some idea of the code.

    2nd Edit: This is just something I have done with this sort of technology. Bear in mind it was quite a while ago. It accepts a name based on the query string and basically does a few loops with a lot of random numbers.

    Here is the source code, I apologize for any stupid code/quotes. This was written quite a while ago, when I was about 14 I believe (probably many flaws).

    <?php
    header("Content-type:image/jpeg");
    $array=array("I am a monument to all your sins", "Currently making pizza","Best before 12/7/09", "Farming Onions");
            function imagettftext_cr(&$im, $size, $angle, $x, $y, $color, $fontfile, $text)
            {
                // retrieve boundingbox
                $bbox = imagettfbbox($size, $angle, $fontfile, $text);
                // calculate deviation
                $dx = ($bbox[2]-$bbox[0])/2.0 - ($bbox[2]-$bbox[4])/2.0;         // deviation left-right
                $dy = ($bbox[3]-$bbox[1])/2.0 + ($bbox[7]-$bbox[1])/2.0;        // deviation top-bottom
                // new pivotpoint
                $px = $x-$dx;
                $py = $y-$dy;
                return imagettftext($im, $size, $angle, $px, $y, $color, $fontfile, $text);
            }
    $image = imagecreate(500,90);
    $black = imagecolorallocate($image,0,0,0);
    $grey_shade = imagecolorallocate($image,40,40,40);
    $white = imagecolorallocate($image,255,255,255);
    
    
    $text = $array[rand(0,sizeof($array)-1)];
    
    // Local font files, relative to script
    $otherFont = 'army1.ttf';
    $font = 'army.ttf';
    
    if($_GET['name'] == ""){ $name = "Sam152";}else{$name= $_GET['name'];}
    $name = substr($name, 0, 25);    
    
    
    //BG text for Name
    while($i<10){
    imagettftext_cr($image,rand(2,40),rand(0,50),rand(10,500),rand(0,200),$grey_shade,$font,$name);
    $i++;
    }
    //BG text for saying
    while($i<10){
    imagettftext_cr($image,rand(0,40),rand(90,180),rand(100,500),rand(200,500),$grey_shade,$otherFont,$text);
    $i++;
    }
    
    // Main Text
    imagettftext_cr($image,35,0,250,46,$white,$font,$name);
    imagettftext_cr($image,10,0,250,76,$white,$otherFont,$text);
    imagejpeg($image);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 135k
  • Answers 135k
  • 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 If you say __PACKAGE__->run(@ARGV) then run can be defined in… May 12, 2026 at 6:57 am
  • Editorial Team
    Editorial Team added an answer If you call nanosleep() to sleep for a second or… May 12, 2026 at 6:57 am
  • Editorial Team
    Editorial Team added an answer Minifying improves performance for your page overall by decreasing the… May 12, 2026 at 6:57 am

Related Questions

Over the last few weeks I have been studying the MVC design pattern for
I was wondering how i should go about writing an XML data layer for
I'd like to create a text input with a clear button in a confined
I have a method that's about ten lines of code. I want to create

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.