Problem with imagecreatefromgif()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

spacebass5000
Forum Newbie
Posts: 11
Joined: Tue Mar 21, 2006 7:31 am

Post by spacebass5000 »

ok, i was looking at that and scratching my chin

i did not write the code so i took it at face value

i shall go try this!

edit: man, you alright... i just noticed you linked me to the php.net docs. i already looked at them, but the fact that you did this rocks
spacebass5000
Forum Newbie
Posts: 11
Joined: Tue Mar 21, 2006 7:31 am

Post by spacebass5000 »

I figured it out. The 3pd application I was using makes painstaking efforts to check the input files yet regardless if they are gif, jpg, or png ends up writing them as jpg's.

Code: Select all

switch($imginfo[2]) {
						case 'JPG':
							$src_img = imagecreatefromjpeg($this->tmpFile);
							break;

						case 'PNG':
							$src_img = imagecreatefrompng($this->tmpFile);
							break;
						
						case 'GIF':
							$src_img = imagecreatefromgif($this->tmpFile);
							break;
					}

					if (!$src_img){
						$ERROR = $lang_errors['invalid_image'];
						return false;
					}
					$dst_img = imagecreatetruecolor($destWidth, $destHeight);
					imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
					
					imagejpeg($dst_img, $this->directory.$this->imageName, $this->quality);
awesome... good stuff, yay even

Thank you so much for your efforts. You totally helped me come to the realization of why this is broke.

karma++ :D
Last edited by spacebass5000 on Tue Mar 21, 2006 5:56 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

glad to help.
Post Reply