This is a discussion on resize an image within the PHP Language forums, part of the PHP Programming Forums category; Hi does anybody know's what's wrong with the following code : if (($imgsize[0] > 250) || ($imgsize[1] > ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi does anybody know's what's wrong with the following code :
if (($imgsize[0] > 250) || ($imgsize[1] > 200)) { $tmpimg = tempnam("/avatard", "MKUP"); system("djpeg $file >$tmpimg"); system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file"); copy($file, "avatard/" . $nom_utilisateur.".jpeg"); unlink($tmpimg); } image 're not resized :( thanks in advance |
|
|||
|
Alexandre Jaquet wrote:
> Hi does anybody know's what's wrong with the following code : This code lacks a lot of error checking > if (($imgsize[0] > 250) || ($imgsize[1] > 200)) { > $tmpimg = tempnam("/avatard", "MKUP"); if ($tmpimg === false) die('Cannot create temporary filename.'); > ## system("djpeg $file >$tmpimg"); system("djpeg $file >$tmpimg", $status_code); /* assuming a status code of 1 or greater is an error */ if ($status_code > 1) die('Error executing djpeg.'); > system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file"); > ## copy($file, "avatard/" . $nom_utilisateur.".jpeg"); if (!copy($file, "avatard/" . $nom_utilisateur.".jpeg")) { /* probably an error */ } > ## unlink($tmpimg); if (!unlink($tmpimg)) { /* unable to delete the file */ /* die() or do something else */ } > } > image 're not resized :( As for the system calls (djpeg and pnmscale) I have no idea if they're wrong or right, if they worked or not ... and neither have you :-) -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address! |