| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Feb 2004
Posts: 720
![]() ![]() | imagecreatefrom Problem Hi guys, I'm trying to modify the counter code script to use .jpg filenames instead of the standard .png filenames to help speed counter image loading times up a bit. I'm having a problem getting "imagecreatefrompng" to work properly. I have changed all references of .png to .jpg and all remaining references of png to jpeg (the ones that don't call a file name.ext). The server has GD ver. 2.0.28 with jpeg support installed. admin.php Code: for ($i = 1; $i < $total; $i++){
$filename = "images/" . ${i.$i.filename} . ".jpg";
if (is_file($filename)){
mysql_query("UPDATE CC_image SET id=".${i.$i.id}.", filename='".${i.$i.filename}."', xpos=".${i.$i.xpos}.", ypos=".${i.$i.ypos}.", is_stealth='".${i.$i.is_stealth}."' WHERE id=".${i.$i.id}) or $error=mysql_error();
} else {
$error .= $filename . " " . $lang['counter_not_found1']."$id".$lang['counter_not_found2']."<br><br>";
break; ????: NamePros.com http://www.namepros.com/code/55802-imagecreatefrom-problem.html core.class.php Code: $output.= "> </td><td nowrap><img src=images/" . $this->d->filename . ".jpg alt='counter no " . $this->d->id . "'>";
if($this->d->is_stealth == 1)
$output.= " <font size=\"1\">(".$lang['stealth_mode'].")</font>";
$output.= "</td>";
if($i%2!=0)
$output.= "</tr>"; Code: $this->image = "images/" . $this->d->filename . ".jpg"; Code: header('Content-type: image/jpeg');
$this->im=imagecreatefromjpeg($this->image);
$this->w=imagecolorallocate($this->im, 0, 0, 0); Code: imagejpeg($this->im); flush(); imagedestroy($this->im); ????: NamePros.com http://www.namepros.com/showthread.php?t=55802 Code: header('Content-type: image/jpeg');
$this->image = "images/" . $_GET['filename'] . ".jpg";
$this->im=imagecreatefromjpeg($this->image);
$this->w=imagecolorallocate($this->im, 0, 0, 0);
if($_GET['is_stealth']=='0'){
if (!isset($testNumber))
$testNumber = "123";
imagestring($this->im,3,$_GET['locx'],$_GET['locy'],$testNumber,$this->w);
}
imagejpeg($this->im);
flush();
imagedestroy($this->im); |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Regular Join Date: Feb 2004
Posts: 720
![]() ![]() | Thanks for the reply. I get these errors in the error logs over and over and over [Tue Nov 16 09:32:13 2004] [error] PHP Fatal error: Call to undefined function: imagejpg() in /home/stats/public_html/stats/imagetest.php on line 18 [Tue Nov 16 09:32:13 2004] [error] PHP Warning: imagestring(): supplied argument is not a valid Image resource in /home/stats/public_html/stats/imagetest.php on line 14 [Tue Nov 16 09:32:13 2004] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/stats/public_html/stats/imagetest.php on line 8 [Tue Nov 16 09:32:13 2004] [error] PHP Warning: imagecreatefromjpeg(/images/14.jpg): failed to open stream: No such file or directory in /home/stats/public_html/stats/imagetest.php on line 7 http://www.swiftstats.com/stats/imagetest.php shows the following error: "The image “http://www.swiftstats.com/stats/imagetest.php” cannot be displayed, because it contains errors." |
| |
| | #4 (permalink) |
| Senior Member Join Date: May 2003
Posts: 2,187
![]() ![]() ![]() | PHP Fatal error: Call to undefined function: imagejpg() in i was getting this error and fixed it, and its something to do with jpeg wasnt compiled wiht php can you make a phpinfo and post the link here so i can lookat something. |
| |
| | #6 (permalink) |
| Senior Member Join Date: May 2003
Posts: 2,187
![]() ![]() ![]() | hmmmmmmm the php info pretty much matches mine for gd silly question, has the webserver been reloaded since you compiled php with gd and jpeg support or is this something your host would have done? also when visiting php.net/imagejpg it refers me to a page and the title imagejpeg maybe change imagejpg in your code to imagejpeg |
| |
| | THREAD STARTER #7 (permalink) |
| NamePros Regular Join Date: Feb 2004
Posts: 720
![]() ![]() | As far as I know, the server hasn't been reloaded. The host would take care of this, but he's usually pretty good about letting customers know if there is going to be any kind of change. I'll try changing imagejpg to imagejpeg and let you know what it does. |
| |
| | THREAD STARTER #10 (permalink) |
| NamePros Regular Join Date: Feb 2004
Posts: 720
![]() ![]() | These are the latest errors from the logs. ????: NamePros.com http://www.namepros.com/showthread.php?t=55802 [Wed Nov 17 18:18:54 2004] [error] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/stats/public_html/stats/imagetest.php on line 20 [Wed Nov 17 18:18:54 2004] [error] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/stats/public_html/stats/imagetest.php on line 18 [Wed Nov 17 18:18:54 2004] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/stats/public_html/stats/imagetest.php on line 8 [Wed Nov 17 18:18:54 2004] [error] PHP Warning: imagecreatefromjpeg(images/.jpg): failed to open stream: No such file or directory in /home/stats/public_html/stats/imagetest.php on line 7 |
| |