Image_Problem
--00163649a6036944f8046f52de43
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi All, I wanna ask a question pleasenV. I am trying to create an image on
fly, please do help me , following is the code.
*File Name : Font.php
Code: *
<html>
<head>
<title>Image Creation</title>
<script language="javascript">
var xmlhttp;
function showPic()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var text = document.getElementById("textfield").value;
var url="image.php";
url=url+"?text="text;
alert(url);
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
if(xmlhttp.responseText == 1)
{
document.getElementById("pic").style.display="block";
}
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
</head>
<body>
<form name="form1" method="post" action="" onSubmit=" return false;">
<table width="304" border="1">
<tr>
<td colspan="2"><div align="center">Text</div></td>
</tr>
<tr>
<td>Text</td>
<td><label>
<input type="text" name="textfield" id="textfield">
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="button" id="button" value="Update"
onClick="showPic()">
</div>
</label></td>
</tr>
<tr>
<td colspan="2"><div id="pic" style="display:none"><img src="pic.jpg"
/></div></td>
</tr>
</table>
</form>
</body>
</html>
*File Name : image.php
Code:*
[php]
$name = $_GET['text'];
$pic = imagecreatetruecolor(100, 100);
$text_color = imagecolorallocate($pic, 255, 255, 255);
imagestring($pic, 10, 15, 15, $name, $text_color);
$pi = Imagejpeg($pic,"pic.jpg");
echo $pi;
ImageDestroy($pic);
[/php]
*Problem: *
What this code is doing is that, it creates a new image with the text (that
user enters) on it, but loads the image that was created previously, I want
that it should display the text on the picture which users enter on the fly.
( e.g. If user enter TEXT as text it should display TEXT on the picture
displayed, soon after we get response from ajax).I hope you got the problem.
Thanks
--00163649a6036944f8046f52de43--
Re: Image_Problem
2009/7/22 Bilal Ahmad <engg.bilalmalik [at] googlemail.com>:
> Hi All, I wanna ask =C2=A0a question pleasenV. I am trying to create an i=
mage on
> fly, please do help me , following is the code.
>
> *File Name : Font.php
> Code: *
>
> <html>
> <head>
> <title>Image Creation</title>
>
> <script language=3D"javascript">
> var xmlhttp;
>
> function showPic()
> {
> xmlhttp=3DGetXmlHttpObject();
> if (xmlhttp=3D=3Dnull)
> =C2=A0{
> =C2=A0alert ("Browser does not support HTTP Request");
> =C2=A0return;
> =C2=A0}
>
> var text =3D document.getElementById("textfield").value;
>
> var url=3D"image.php";
> url=3Durl+"?text=3D"text;
> alert(url);
> url=3Durl+"&sid=3D"+Math.random();
> xmlhttp.onreadystatechange=3DstateChanged;
> xmlhttp.open("GET",url,true);
> xmlhttp.send(null);
> }
>
> function stateChanged()
> {
> if (xmlhttp.readyState=3D=3D4)
> {
> if(xmlhttp.responseText =3D=3D 1)
> {
> document.getElementById("pic").style.display=3D"block";
> }
> }
> }
>
> function GetXmlHttpObject()
> {
> if (window.XMLHttpRequest)
> =C2=A0{
> =C2=A0// code for IE7+, Firefox, Chrome, Opera, Safari
> =C2=A0return new XMLHttpRequest();
> =C2=A0}
> if (window.ActiveXObject)
> =C2=A0{
> =C2=A0// code for IE6, IE5
> =C2=A0return new ActiveXObject("Microsoft.XMLHTTP");
> =C2=A0}
> return null;
> }
> </script>
> </head>
> <body>
> <form name=3D"form1" method=3D"post" action=3D"" onSubmit=3D" return fals=
e;">
> =C2=A0<table width=3D"304" border=3D"1">
> =C2=A0 =C2=A0<tr>
> =C2=A0 =C2=A0 =C2=A0<td colspan=3D"2"><div align=3D"center">Text</div></t=
d>
> =C2=A0 =C2=A0</tr>
> =C2=A0 =C2=A0<tr>
> =C2=A0 =C2=A0 =C2=A0<td>Text</td>
> =C2=A0 =C2=A0 =C2=A0<td><label>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0<input type=3D"text" name=3D"textfield" id=3D"=
textfield">
> =C2=A0 =C2=A0 =C2=A0</label></td>
> =C2=A0 =C2=A0</tr>
> =C2=A0 =C2=A0<tr>
> =C2=A0 =C2=A0 =C2=A0<td colspan=3D"2"><label>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0<div align=3D"center">
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<input type=3D"submit" name=3D"button" =
id=3D"button" value=3D"Update"
> onClick=3D"showPic()">
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</div>
> =C2=A0 =C2=A0 =C2=A0</label></td>
> =C2=A0 =C2=A0</tr>
> =C2=A0 =C2=A0<tr>
> =C2=A0 =C2=A0 =C2=A0<td colspan=3D"2"><div id=3D"pic" style=3D"display:no=
ne"><img src=3D"pic.jpg"
> /></div></td>
> =C2=A0 =C2=A0</tr>
> =C2=A0</table>
> </form>
> </body>
> </html>
>
> *File Name : image.php
> Code:*
>
> [php]
>
> $name =3D $_GET['text'];
>
> =C2=A0$pic =3D imagecreatetruecolor(100, 100);
> =C2=A0$text_color =3D imagecolorallocate($pic, 255, 255, 255);
> =C2=A0imagestring($pic, 10, 15, 15, =C2=A0$name, $text_color);
> =C2=A0$pi =3D Imagejpeg($pic,"pic.jpg");
> =C2=A0echo $pi;
> =C2=A0ImageDestroy($pic);
>
> [/php]
>
> *Problem: *
>
> What this code is doing is that, it creates a new image with the text (th=
at
> user enters) on it, but loads the image that was created previously, I wa=
nt
> that it should display the text on the picture which users enter on the f=
ly.
> ( e.g. If user enter TEXT as text it should display TEXT on the picture
> displayed, soon after we get response from ajax).I hope you got the probl=
em.
>
>
> Thanks
>
Try changing ...
$pi =3D Imagejpeg($pic,"pic.jpg");
echo $pi;
to ...
imagejpeg($pic);
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Image_Problem
--00163645950a93873b046f6231a7
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi All, Thanx Richard for your reply, but it isn't working either, please
help me out, Thanks. I can explain the problem again if some one has ne
problem in understanding of the problem. Thanks
On Thu, Jul 23, 2009 at 2:21 PM, Richard Quadling
<rquadling [at] googlemail.com>wrote:
> 2009/7/22 Bilal Ahmad <engg.bilalmalik [at] googlemail.com>:
> > Hi All, I wanna ask a question pleasenV. I am trying to create an image
> on
> > fly, please do help me , following is the code.
> >
> > *File Name : Font.php
> > Code: *
> >
> > <html>
> > <head>
> > <title>Image Creation</title>
> >
> > <script language="javascript">
> > var xmlhttp;
> >
> > function showPic()
> > {
> > xmlhttp=GetXmlHttpObject();
> > if (xmlhttp==null)
> > {
> > alert ("Browser does not support HTTP Request");
> > return;
> > }
> >
> > var text = document.getElementById("textfield").value;
> >
> > var url="image.php";
> > url=url+"?text="text;
> > alert(url);
> > url=url+"&sid="+Math.random();
> > xmlhttp.onreadystatechange=stateChanged;
> > xmlhttp.open("GET",url,true);
> > xmlhttp.send(null);
> > }
> >
> > function stateChanged()
> > {
> > if (xmlhttp.readyState==4)
> > {
> > if(xmlhttp.responseText == 1)
> > {
> > document.getElementById("pic").style.display="block";
> > }
> > }
> > }
> >
> > function GetXmlHttpObject()
> > {
> > if (window.XMLHttpRequest)
> > {
> > // code for IE7+, Firefox, Chrome, Opera, Safari
> > return new XMLHttpRequest();
> > }
> > if (window.ActiveXObject)
> > {
> > // code for IE6, IE5
> > return new ActiveXObject("Microsoft.XMLHTTP");
> > }
> > return null;
> > }
> > </script>
> > </head>
> > <body>
> > <form name="form1" method="post" action="" onSubmit=" return false;">
> > <table width="304" border="1">
> > <tr>
> > <td colspan="2"><div align="center">Text</div></td>
> > </tr>
> > <tr>
> > <td>Text</td>
> > <td><label>
> > <input type="text" name="textfield" id="textfield">
> > </label></td>
> > </tr>
> > <tr>
> > <td colspan="2"><label>
> > <div align="center">
> > <input type="submit" name="button" id="button" value="Update"
> > onClick="showPic()">
> > </div>
> > </label></td>
> > </tr>
> > <tr>
> > <td colspan="2"><div id="pic" style="display:none"><img
> src="pic.jpg"
> > /></div></td>
> > </tr>
> > </table>
> > </form>
> > </body>
> > </html>
> >
> > *File Name : image.php
> > Code:*
> >
> > [php]
> >
> > $name = $_GET['text'];
> >
> > $pic = imagecreatetruecolor(100, 100);
> > $text_color = imagecolorallocate($pic, 255, 255, 255);
> > imagestring($pic, 10, 15, 15, $name, $text_color);
> > $pi = Imagejpeg($pic,"pic.jpg");
> > echo $pi;
> > ImageDestroy($pic);
> >
> > [/php]
> >
> > *Problem: *
> >
> > What this code is doing is that, it creates a new image with the text
> (that
> > user enters) on it, but loads the image that was created previously, I
> want
> > that it should display the text on the picture which users enter on the
> fly.
> > ( e.g. If user enter TEXT as text it should display TEXT on the picture
> > displayed, soon after we get response from ajax).I hope you got the
> problem.
> >
> >
> > Thanks
> >
>
> Try changing ...
>
> $pi = Imagejpeg($pic,"pic.jpg");
> echo $pi;
>
> to ...
>
> imagejpeg($pic);
>
>
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
> ZOPA : http://uk.zopa.com/member/RQuadling
>
--00163645950a93873b046f6231a7--