resize an image

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] > ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-29-2004
Alexandre Jaquet
 
Posts: n/a
Default resize an image

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

Reply With Quote
  #2 (permalink)  
Old 12-29-2004
Pedro Graca
 
Posts: n/a
Default Re: resize an image

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!
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:59 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0