resize an image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexandre Jaquet

    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("pnmscal e -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file");
    copy($file, "avatard/" . $nom_utilisateu r.".jpeg");
    unlink($tmpimg) ;
    }

    image 're not resized :(

    thanks in advance

  • Pedro Graca

    #2
    Re: resize an image

    Alexandre Jaquet wrote:[color=blue]
    > Hi does anybody know's what's wrong with the following code :[/color]

    This code lacks a lot of error checking
    [color=blue]
    > if (($imgsize[0] > 250) || ($imgsize[1] > 200)) {
    > $tmpimg = tempnam("/avatard", "MKUP");[/color]

    if ($tmpimg === false) die('Cannot create temporary filename.');
    [color=blue]
    > ## system("djpeg $file >$tmpimg");[/color]

    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.');

    [color=blue]
    > system("pnmscal e -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file");
    > ## copy($file, "avatard/" . $nom_utilisateu r.".jpeg");[/color]

    if (!copy($file, "avatard/" . $nom_utilisateu r.".jpeg")) {
    /* probably an error */
    }
    [color=blue]
    > ## unlink($tmpimg) ;[/color]

    if (!unlink($tmpim g)) {
    /* unable to delete the file */
    /* die() or do something else */
    }
    [color=blue]
    > }[/color]
    [color=blue]
    > image 're not resized :([/color]

    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!

    Comment

    Working...