Images and Aspect Ratio Help Needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralph Freshour

    #1

    Images and Aspect Ratio Help Needed

    I'm trying to figure out how to write some php code that will allow me
    to resize a .jpg image and maintain it's aspect ratio - any help or
    idea's would be appreciated.

    Thanks...

  • Steven Musumeche

    #2
    Re: Images and Aspect Ratio Help Needed

    function thumbnail($imag e_path,$thumb_p ath,$image_name ,$thumb_width)
    {
    $src_img = imagecreatefrom jpeg("$image_pa th/$image_name");
    $origw=imagesx( $src_img);
    $origh=imagesy( $src_img);
    if ($origw>$origh)
    {
    $new_w = $thumb_width;
    $diff=$new_w/$origw;
    $new_h=$origh*$ diff;
    }
    else
    {
    $new_h = $thumb_width;
    $diff=$new_h/$origh;
    $new_w=$origw*$ diff;
    }
    $dst_img = imagecreatetrue color($new_w,$n ew_h);

    imagecopyresamp led($dst_img,$s rc_img,0,0,0,0, $new_w,$new_h,i magesx($src_img )
    ,imagesy($src_i mg));
    imagejpeg($dst_ img, "$thumb_pat h/th_$image_name" );
    return true;
    }


    "Ralph Freshour" <ralph@primemai l.com> wrote in message
    news:nsttqvs5ft 6evj2s2p3dkau5k dq9rklres@4ax.c om...[color=blue]
    > I'm trying to figure out how to write some php code that will allow me
    > to resize a .jpg image and maintain it's aspect ratio - any help or
    > idea's would be appreciated.
    >
    > Thanks...
    >[/color]


    Comment

    Working...