www.webdeveloper.com
Results 1 to 4 of 4

Thread: Pic resize script needs file types added...

  1. #1
    Join Date
    Jan 2006
    Posts
    301

    Pic resize script needs file types added...

    I have a script below that resizes a jpg images. Currently only jpg files work. Can anyone tell me how to get .gif, .png, and possibly .tif and .pdf pictures to work in this script.

    Thanks!


    <?php
    // The file
    $filename = $_REQUEST['photo'];
    $wid=625;

    // Content type
    header('Content-type: image/jpeg');
    header('Content-length: '.filesize($filename));

    // Get new dimensions
    list($width, $height) = getimagesize($filename);
    $new_width = $wid;
    $widthratio = $new_width / $width;
    $new_height = $height * $widthratio;

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

    // Output
    imagejpeg($image_p, null, 100);
    ?>
    www.unitingbands.com - Where Talents Unite!

  2. #2
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742

  3. #3
    Join Date
    Dec 2006
    Location
    Escaz˙ (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    There you go... cheating again... Incorrigible...

  4. #4
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742
    Quote Originally Posted by NightShift58
    There you go... cheating again... Incorrigible...
    That's part of the 95% of code I told you about! What should I have done differently?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles