Page 1 of 1

Resizing image error

Posted: Fri Oct 11, 2002 12:15 am
by ace2600
I recently changed host and all my code works on the new host except for my resizing image code (if they submit a pic, it resizes it to a smaller size) which worked on my old host. The code runs fine (no errors), but when it uploads the image after it resizes it, it uploads an empty file (only if it resizes).

My old host had PHP v.4.2.1 while my new host has 4.2.3. Is any of the code not supported in the newer version? If not, what could be the problem? if you need more info I'll be glad to give it.

Code: Select all

/*== check size  0=width, 1=height ==*/
if (($imgsizeї0] > 250) || ($imgsizeї1] > 200)) 
{
/*== temp image file -- use "tempnam()" to generate the temp file name. This is done so if multiple people access the script at once they won't ruin each other's temp file ==*/
$tmpimg = tempnam("/tmp", "MKUP");
				
/*== RESIZE PROCESS
							 1. decompress jpeg image to pnm file (a raw image type) 
							 2. scale pnm image
							 3. compress pnm file to jpeg image==*/
						
/*== Step 1: djpeg decompresses jpeg to pnm ==*/
system("djpeg $imgfile1 >$tmpimg");
						
				
/*== Steps 2&3: scale image using pnmscale and then pipe into cjpeg to output jpeg file ==*/
system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile1");
				
/*== remove temp image ==*/
unlink($tmpimg);
}
I'm thinking it has something to do with the system function, but really have no idea. Thanks.
-Ace