NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page imagecreatefrom Problem

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.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 11-16-2004, 04:44 PM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



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>";
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
????: 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);
Any help with this would be appreciated.
Caveman is offline  
Old 11-17-2004, 05:39 AM   #2 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
what errors if any are you getting?
adam_uk is offline  
Old 11-17-2004, 07:35 AM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



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."
Caveman is offline  
Old 11-17-2004, 07:47 AM   #4 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
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.
adam_uk is offline  
Old 11-17-2004, 10:12 AM THREAD STARTER               #5 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



Hi Adam,
Here is the link to the php info.

http://swiftstats.com/stats/phpinfo.php

Regards,
Mike
Caveman is offline  
Old 11-17-2004, 02:53 PM   #6 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
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
adam_uk is offline  
Old 11-17-2004, 06:04 PM THREAD STARTER               #7 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



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.
Caveman is offline  
Old 11-17-2004, 06:26 PM THREAD STARTER               #8 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



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
Caveman is offline  
Old 11-18-2004, 01:20 AM   #9 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
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
adam_uk is offline  
Old 11-18-2004, 07:56 AM THREAD STARTER               #10 (permalink)
NamePros Regular
Join Date: Feb 2004
Posts: 720
Caveman has a spectacular aura aboutCaveman has a spectacular aura about
 



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
Caveman is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:27 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger