Images and Aspect Ratio Help Needed

Ask a Question related to PHP Development, Design and Development.

  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. Similar Questions and Discussions

    1. Resize Imges maintaining aspect ratio
      I want to do a page like web photo album. I want to show some thumbnails and when i click on it, it should open the image with the original size!...
    2. constrain aspect ratio
      Hi. FH MX User 1.When I want to change the size of my object (w or h) here a logo on object panel,( even when I check "transform as unit" ) it...
    3. Locking aspect ratio to 4x3 NOT 16x9
      Hi. I have developed a swf presentation at 4x3 ratio. Now it will be shown on a 16x9 machine and everything is stretched. Is their a way with code I...
    4. Resizing Movies to fit res...but keeping aspect ratio.
      OK...I've looked for this soultion around but I havent found it. Basically I have a page with flash (www.madisyn.com , click on "knight" image,...
    5. wntd: true 8/10 ,5/7 pictures , despite aspect ratio ?
      Hi, I don't know about the software you are using but in Photoshop Elements 2 you can set the dimensions of the crop tool to whatever you want...
  3. #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" <ralph@primemail.com> wrote in message
    news:nsttqvs5ft6evj2s2p3dkau5kdq9rklres@4ax.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

Posting Permissions

  • You may not post new threads
  • You may 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