Image Resizer Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Image Resizer Help

    this is the image resizer for .jpg files only,can any1 edit it,which will work for .gif and .png files also?<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php
    // The file
    $filename = &#39;test.jpg&#39;;

    // Set a maximum height and width
    $width = 200;
    $height = 200;

    // Content type
    header(&#39;Content-type: image/jpeg&#39;);

    // Get new dimensions
    list($width_orig, $height_orig) = getimagesize($filename);

    $ratio_orig = $width_orig/$height_orig;

    if ($width/$height > $ratio_orig) {
    $width = $height*$ratio_orig;
    } else {
    $height = $width/$ratio_orig;
    }

    // Resample
    $image_p = imagecreatetruecolor($width, $height);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

    // Output
    imagejpeg($image_p, null, 100);
    ?></div>

    #2
    i presume you can by just adding few more Content-type: image/gif or Content-type: image/png yadda yadda thingys
    and add summat like imagegif($image_p, null, 100) or something at the end

    Comment


      #3
      i presume you can by just adding few more Content-type: image/gif or Content-type: image/png yadda yadda thingys
      and add summat like imagegif($image_p, null, 100) or something at the end[/b]
      u hv forgotten to mention this variable $image = imagecreatefromjpeg($filename);

      anyway i hv tried ur mentioned way but PHP didnt listen my edited codes,thats why i had to open this topic

      Comment


        #4
        Code:
        [url=" IMAGE URL "][img] IMAGE URL [/img][/url]
        Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
        Visit: WapMasterz Coming Back Soon!
        _______
        SCRIPTS FOR SALE BY SUBZERO
        Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
        FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
        _______
        Info & Tips
        php.net
        w3schools.com

        Comment


          #5
          Code:
          [url=" IMAGE URL "][img] IMAGE URL [/img][/url]
          [/b]

          i want to get a thumb view of .gif,.png files also ur this ref will never solve it bro

          Comment


            #6
            there no way yet bro if ya wait ill make a images ok
            Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
            Visit: WapMasterz Coming Back Soon!
            _______
            SCRIPTS FOR SALE BY SUBZERO
            Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
            FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


              #7
              there no way yet bro if ya wait ill make a images ok[/b]
              here is a code,but i cant combine the both codes<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php

              $taille = getimagesize("$pic");
              $h_i = $taille[1];
              $w_i = $taille[0];
              if($h_i >$h_max)
              {
              $convert=$h_max/$h_i;
              $h_i=$h_max;
              $w_i=ceil($w_i*$convert);
              }
              if($w_i >$w_max)
              {
              $convert=$w_max/$w_i;
              $w_i=$w_max;
              $h_i=ceil($h_i*$convert);
              };

              $largeur = "$w_i";
              $hauteur ="$h_i";

              header("Content-Type: image/jpeg");
              list($width, $height, $type, $attr) = getimagesize("$pic");

              if($type == "1")
              {
              $img_in = imagecreatefromgif($pic);
              }

              if($type == "2")
              {
              $img_in = imagecreatefromjpeg($pic);
              }

              if($type == "3")
              {
              $img_in = imagecreatefrompng($pic);
              }

              $img_out = imagecreatetruecolor($largeur, $hauteur);
              imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
              imagejpeg($img_out, null, 100);
              ?></div>

              Comment


                #8
                Code:
                <?php
                header ("Content-type: image/jpeg");
                $img = $_GET[&#39;img&#39;];
                $percent = $_GET[&#39;percent&#39;];
                $constrain = $_GET[&#39;constrain&#39;];
                $w = $_GET[&#39;w&#39;];
                $h = $_GET[&#39;h&#39;];
                $x = @getimagesize($img);
                $sw = $x[0];
                $sh = $x[1];
                if ($percent > 0) {
                $percent = $percent * 0.01;
                $w = $sw * $percent;
                $h = $sh * $percent;
                } else {
                if (isset ($w) AND !isset ($h)) {
                $h = (100 / ($sw / $w)) * .01;
                $h = @round ($sh * $h);
                } elseif (isset ($h) AND !isset ($w)) {
                $w = (100 / ($sh / $h)) * .01;
                $w = @round ($sw * $w);
                } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) {
                $hx = (100 / ($sw / $w)) * .01;
                $hx = @round ($sh * $hx);
                $wx = (100 / ($sh / $h)) * .01;
                $wx = @round ($sw * $wx);
                if ($hx < $h) {
                $h = (100 / ($sw / $w)) * .01;
                $h = @round ($sh * $h);
                }else{
                $w = (100 / ($sh / $h)) * .01;
                $w = @round ($sw * $w);
                }
                }
                }
                $im = @ImageCreateFromJPEG ($img)
                $im = @ImageCreateFromPNG ($img) 
                $im = @ImageCreateFromGIF ($img) 
                $im = false;
                if (!$im) {
                readfile ($img);
                }else{
                $thumb = @ImageCreateTrueColor ($w, $h);
                @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh);
                @ImageJPEG ($thumb);
                }
                ?>
                Now to show ?h=10&amp;w=15&amp;img=


                Now im going to bed try it mite be lucky i did things for ya
                Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                Visit: WapMasterz Coming Back Soon!
                _______
                SCRIPTS FOR SALE BY SUBZERO
                Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                _______
                Info & Tips
                php.net
                w3schools.com

                Comment


                  #9
                  i want help on getting random gallery pictures please post the code someone
                  Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

                  <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

                  Comment


                    #10
                    $sql=mysql_fetch_array(mysql_query("SELECT id, scode, imgsrc FROM ibwf_gallery ORDER BY RAND() LIMIT 1"));
                    echo "<img src=\"$sql[2]\" alt=\"$sql[1]\"/>";

                    thats jus an example

                    Comment


                      #11
                      Random Text, Link, Image With Sql
                      see the script here: http://www.2wap.org/forums/downloads.html&...il&f_id=106
                      http://ngeo.ro

                      Comment


                        #12
                        Code:
                        <?php
                        header ("Content-type: image/jpeg");
                        $img = $_GET[&#39;img&#39;];
                        $percent = $_GET[&#39;percent&#39;];
                        $constrain = $_GET[&#39;constrain&#39;];
                        $w = $_GET[&#39;w&#39;];
                        $h = $_GET[&#39;h&#39;];
                        $x = @getimagesize($img);
                        $sw = $x[0];
                        $sh = $x[1];
                        if ($percent > 0) {
                        $percent = $percent * 0.01;
                        $w = $sw * $percent;
                        $h = $sh * $percent;
                        } else {
                        if (isset ($w) AND !isset ($h)) {
                        $h = (100 / ($sw / $w)) * .01;
                        $h = @round ($sh * $h);
                        } elseif (isset ($h) AND !isset ($w)) {
                        $w = (100 / ($sh / $h)) * .01;
                        $w = @round ($sw * $w);
                        } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) {
                        $hx = (100 / ($sw / $w)) * .01;
                        $hx = @round ($sh * $hx);
                        $wx = (100 / ($sh / $h)) * .01;
                        $wx = @round ($sw * $wx);
                        if ($hx < $h) {
                        $h = (100 / ($sw / $w)) * .01;
                        $h = @round ($sh * $h);
                        }else{
                        $w = (100 / ($sh / $h)) * .01;
                        $w = @round ($sw * $w);
                        }
                        }
                        }
                        $im = @ImageCreateFromJPEG ($img)
                        $im = @ImageCreateFromPNG ($img) 
                        $im = @ImageCreateFromGIF ($img) 
                        $im = false;
                        if (!$im) {
                        readfile ($img);
                        }else{
                        $thumb = @ImageCreateTrueColor ($w, $h);
                        @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh);
                        @ImageJPEG ($thumb);
                        }
                        ?>
                        Now to show ?h=10&amp;w=15&amp;img=
                        Now im going to bed try it mite be lucky i did things for ya [/b]
                        thanks but it wont work as the MIME TYPE is only for jpeg

                        Comment

                        Working...
                        X