Jump to content

[SOLVED] saving an image in php


Asperon

Recommended Posts

well either way its not saving.... I think I have things all messed up anyways, I would post code, but there's a bit too much to read through...basically, I have form that you fill out...and you hit update...and it is supposed to display the image you created using the form.... I have the form run and i include the php file with the image function...but the png comes out as a that wierd code and I don't know how to <img> embed when it isn't from another file, so I was gonna try saving it.. but I don't think that's the best way.

 

here's the set up

 

 

 

image.php ---> update ---> $_GET inside of image.php ---> include the createImage() function (parameters are from $_GET) ---> imgPNG($im) (this part doesn't show properly)

 

image.php :

<?php

$bgColor = $_GET['bgColor'];
$logo = $_GET['logo'];

$ln1[0] = $_GET['ln1_text'];
$ln1[1] = $_GET['ln1_font'];
$ln1[2] = $_GET['ln1_size'];
$ln1[3] = $_GET['ln1_color'];
$ln1[4] = $_GET['ln1_align'];

$ln2[0] = $_GET['ln2_text'];
$ln2[1] = $_GET['ln2_font'];
$ln2[2] = $_GET['ln2_size'];
$ln2[3] = $_GET['ln2_color'];
$ln2[4] = $_GET['ln2_align'];

$ln3[0] = $_GET['ln3_text'];
$ln3[1] = $_GET['ln3_font'];
$ln3[2] = $_GET['ln3_size'];
$ln3[3] = $_GET['ln3_color'];
$ln3[4] = $_GET['ln3_align'];

$ln4[0] = $_GET['ln4_text'];
$ln4[1] = $_GET['ln4_font'];
$ln4[2] = $_GET['ln4_size'];
$ln4[3] = $_GET['ln4_color'];
$ln4[4] = $_GET['ln4_align'];

$ln5[0] = $_GET['ln5_text'];
$ln5[1] = $_GET['ln5_font'];
$ln5[2] = $_GET['ln5_size'];
$ln5[3] = $_GET['ln5_color'];
$ln5[4] = $_GET['ln5_align'];

?>

<html>
<body>
<head><title>Customize</title></head>

<form method="GET" action="image.php">


//forms

</form>

<?php

include('imageDisplay.php');
createImage($bgColor,$logo,$ln1,$ln2,$ln3,$ln4,ln5);

?>
</body>
</html>

 

 

imageDisplay.php:

 

<?php

function createImage($bgColor, $logo, $ln1, $ln2, $ln3, $ln4, $ln5){

//create canvas
$width = 500;
$height = 203;
$im = ImageCreateTrueColor($width,$height);
switch($bgColor){

case 'Black' :
   $canvas = ImageColorAllocate($im,0,0,0);
   break;
case 'White' :
   $canvas = ImageColorAllocate($im,255,255,255);


//more code...

//create and destroy
Header('Content-type: image/png');
ImagePNG($im)
ImageDestroy($im);
}
?>

Link to comment
Share on other sites

ok, so if I set my image.php to $_GET to imageDisplay.php, and have imageDisplay request all the variables, then define the function, then output,it works, though, some of my fonts dont' work, I need to check that, but it will output...I think that I will go with that for now and add some design to the imageDisplay.php page and let the user decide whether to keep it or do something else with it, thank you for you help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.