Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem: Creating Images

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi all,

I read the php manual about creating images on http://www.php.net/manual/en/features.images.php and just copy and paste the code:

<?php
Header(&quot;Content-type: image/png&quot;);
$string=implode($argv,&quot; &quot;);
$im = ImageCreateFromPng(&quot;images/button1.png&quot;);
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImagePng($im);
ImageDestroy($im);
?>

and I uploaded it to my webserver to test it cause I found it a good idea to use it for page counters.

But I got the following error when I browse the file via IE:

<br>
<b>Warning</b>: imagecreatefrompng: Unable to open 'images/button1.png' for reading in <b>/path/to/the/file/CreateImage.php</b> on line <b>4</b><br>
<br>
<b>Warning</b>: Supplied argument is not a valid Image resource in <b>/path/to/the/file/CreateImage.php</b> on line <b>5</b><br>
<br>
<b>Warning</b>: Supplied argument is not a valid Image resource in <b>/path/to/the/file/CreateImage.php</b> on line <b>6</b><br>
<br>
<b>Warning</b>: Supplied argument is not a valid Image resource in <b>/path/to/the/file/CreateImage.php</b> on line <b>7</b><br>
<br>
<b>Warning</b>: Supplied argument is not a valid Image resource in <b>/path/to/the/file/CreateImage.php</b> on line <b>8</b><br>
<br>
<b>Warning</b>: Supplied argument is not a valid Image resource in <b>/path/to/the/file/CreateImage.php</b> on line <b>9</b><br>

Whats wrong? And how can I get the benefit from createImage command via php script?

And any idea how can I create a simple but strong script for page counter cause my web host's counter is realy poor cause its not storing the IP address it just count how many times the page opened.

HaVe a GooD DaY ;)

@li
 
Does the webserver user have access to read/execute the image? Is it located where PHP is looking for it?
For the counter, just make a database table with an IP column, a count column and whatever other information you want to put in there. Then just retrieve the sum of all the count columns and make an image out of it. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top