Can Some1 Plz Recode This To Make Every Image Show?

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

    Can Some1 Plz Recode This To Make Every Image Show?

    <?php
    $height= 150;
    $width= 150;
    // Content type
    header(&#39;Content-type: image/jpeg&#39;);
    header(&#39;Content-type: image/jpg&#39;);
    header(&#39;Content-type: image/gif&#39;);
    header(&#39;Content-type: image/png&#39;);
    if(!$filename)
    $filename="./images/nopic.jpg";
    // Get new dimensions
    list($width_orig, $height_orig) = getimagesize($filename);

    if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
    } else {
    $height = ($width / $width_orig) * $height_orig;
    }

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

    // Output
    imagejpeg($image_p, null, 100);
    imagejpg($image_p, null, 100);
    imagegif($image_p, null, 100);
    imagePNG($image_p, null, 100);
    ImageDestroy ($image_p);
    ?>

    #2
    HOW DO I GET ALL FOPRMAT OF IMAGES TO SHOW???

    Comment


      #3
      run them off the image extensions and itll work

      Comment


        #4
        HOW? jus recode it n post it here

        Comment


          #5
          hi,

          you may use this, for all images:

          <?php

          function imageResize($width, $height, $target) {

          //takes the larger size of the width and height and applies the
          //formula accordingly...this is so this script will work
          //dynamically with any size image

          if ($width > $height) {
          $percentage = ($target / $width);
          } else {
          $percentage = ($target / $height);
          }

          //gets the new value and applies the percentage, then rounds the value
          $width = round($width * $percentage);
          $height = round($height * $percentage);

          //returns the new sizes in html image tag format...this is so you
          //can plug this function inside an image tag and just get the

          return "width=\"$width\" height=\"$height\"";

          }

          ?>


          Before we take our new function on a test drive, we need to get the width and height of the image that we want to display. There is a magical command in PHP called getimagesize() [4]. This command, used properly, will return the image width, height, type, and even the width and height in HTML image tag format (width="x" height="y").

          $mysock = getimagesize("images/sock001.jpg [5]");

          Now, $mysock is an array [6] that holds vital information about the particular image we want to display. In index 0, we have the width ($mysock[0]), and in index 1, we have the height ($mysock[1]). That&#39;s really all we need, in order to get what we want done. Want to see the function... well, function? Here we go!
          The Function in Action

          Let&#39;s say you want to display a list of your beautiful socks, but you want room on the page to show them neatly in a row, and to do that they cannot be larger than 150 pixels tall or wide.
          http://ngeo.ro

          Comment

          Working...
          X