Domain Empire

Imagecreatefrom Problem

Spaceship
Watch
Impact
8
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;


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>";

counter.class.php
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);

imagetest.php
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);

Any help with this would be appreciated.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
what errors if any are you getting?
 
0
•••
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."
 
0
•••
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.
 
0
•••
0
•••
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
 
1
•••
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.
 
0
•••
Hey Adam,
That worked! I'm still getting the error in imagetest.php, but all the counters are showing up in the admin screen now. I really appreciate the help. $50NP on it's way!

Regards,
Mike
 
0
•••
cool cool glad it worked

can you post the fresh set of errors your getting now? if the scripts working should be fairly simple to fix
 
0
•••
These are the latest errors from the logs.

[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
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back