Jump to content

[SOLVED] Generate an image in php?


pinacoladaxb

Recommended Posts

I want to generate an image based on user inputted data. The best way to describe what I want to do is to use an example...

 

Let's say I want to make a 120 X 120 pixel image that represents user inputted data. I'd have it broken into 4 sections. Each section will hold an image that is a part of the entire image.

Figure%201.jpg

So what I want to do is make user input determine what goes in each square. I want different numbers to mean different pictures. For example...

1 = smile

2 = frown

If the user inputs the text "1221" then I want this image to be generated:

Figure%202.jpg

Can anyone explain how to do this? I've seen similar things done before, so I know it's possible. Remember, I want the final image to be 1 image. Thanks in advance.  :)

 

EDIT: The way the text is inputted will be via POST. The POST string will be "input=(input)." The php page will just need to generate the image.

Link to comment
https://forums.phpfreaks.com/topic/115625-solved-generate-an-image-in-php/
Share on other sites

In the main page

<img src='myimage.php?text=1221'>

 

in "myimage.php"

<?php
$text = $_GET['text'];    //$text now contains 1221

$im = imagecreate(120,120);

// build the image here

header("content-type: image/png");
imagepng($im);
imagedestroy($im);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.