mootools php faith camera linux

php

Resize Images



this is the math:
-----------------------------------
    $newwidth 200;
    
$size $newwidth/$width;
    
$modwidth $width $size;
    
$modheight $height $size;


here is my resize function in php:
-----------------------------------
  function resize() {
    
$file $this->uploadfile;

    
// Setting the resize parameters
    
list($width$height) = getimagesize($file);

    
// set the image to default width of 100
    //$newwidth = (empty($_POST['width'])) ? 100 : $_POST['width'];
    
$newwidth 200;

    
// note that you can use any size you want
    // you have to choose which side of the square is the new size
    // here, i use width...note i also have a comment that
    // allows me to post what size i want the new width to be

    
$size $newwidth/$width;
    
$modwidth $width $size;
    
$modheight $height $size;

    
// there you have it...modheight is the correctly proportioned side

    // Resizing the Image
    
$tn imagecreatetruecolor($modwidth$modheight);
    
$image imagecreatefromjpeg($file);
    
imagecopyresampled($tn$image0000
    
$modwidth$modheight$width$height);

    
// Outputting a .jpg, you can make this gif or png if you want
    //notice we set the quality (third value) to 100
    
imagejpeg($tn$this->uploadfile70);
  } 



Last Updated: 2009-01-08 12:46:59
Creative Commons License Jay Johnston is a Zend Certified Engineer in PHP 5 LPI-ID: LPI000102450, Verfication Code: wmnnt56y2k  ... Jay Johnston is certified as LPIC-1 by the Linux Professional Institute