Image Resizing..Help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samcode3
    New Member
    • Jun 2006
    • 4

    Image Resizing..Help!

    Hi,
    I have a page, where users can upload images, and it will be stored in MySQL as binary data(longblob). Now when i select this data from mysql to display in webpage, i want to resize the picture. Am using PHP/MySQL. Pls help me how to do this..!

    -sam
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I suggest that you first have a look at the standard PHP GD functions. See the PHP manual at http://nl3.php.net/manual/en/ref.image.php

    Ronald :cool:

    Comment

    • tejaswini
      New Member
      • Jul 2006
      • 7

      #3
      hi,
      hope the following code works
      <?php
      // File and new size
      $filename = 'test.jpg';
      $percent = 0.5;

      // Content type
      header('Content-type: image/jpeg');

      // Get new sizes
      list($width, $height) = getimagesize($f ilename);
      $newwidth = $width * $percent;
      $newheight = $height * $percent;

      // Load
      $thumb = imagecreatetrue color($newwidth , $newheight);
      $source = imagecreatefrom jpeg($filename) ;

      // Resize
      imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

      // Output
      imagejpeg($thum b);
      ?>
      taken from php.net website

      Comment

      Working...