By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

resize an image

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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!
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.