Professional Web Applications Themes

Images and Aspect Ratio Help Needed - PHP Development

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

  1. #1

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

    Ralph Freshour Guest

  2. #2

    Default Re: Images and Aspect Ratio Help Needed

    function thumbnail($image_path,$thumb_path,$image_name,$thu mb_width)
    {
    $src_img = imagecreatefromjpeg("$image_path/$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 = imagecreatetruecolor($new_w,$new_h);

    imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_ w,$new_h,imagesx($src_img)
    ,imagesy($src_img));
    imagejpeg($dst_img, "$thumb_path/th_$image_name");
    return true;
    }


    "Ralph Freshour" <ralphprimemail.com> wrote in message
    news:nsttqvs5ft6evj2s2p3dkau5kdq9rklres4ax.com...
    > 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 Guest

Similar Threads

  1. Resize Imges maintaining aspect ratio
    By So_Simple in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: August 16th, 10:22 AM
  2. constrain aspect ratio
    By Reza Saheban in forum Macromedia Freehand
    Replies: 2
    Last Post: May 31st, 04:57 PM
  3. Locking aspect ratio to 4x3 NOT 16x9
    By bpurcella webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 24th, 03:32 PM
  4. Resizing Movies to fit res...but keeping aspect ratio.
    By OrganicJerk webforumsuser@macromedia.com in forum Adobe Flash, Flex & Director
    Replies: 2
    Last Post: September 9th, 09:33 PM
  5. Replies: 0
    Last Post: July 13th, 04:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139