File "code_image.php"

Full Path: /home/analogde/www/New/update/code_image.php
File size: 828 bytes
MIME-type: text/x-php
Charset: utf-8

<?php 

function resizeImage($filename, $max_width, $max_height)
{
    list($orig_width, $orig_height) = getimagesize($filename);

    $width = $orig_width;
    $height = $orig_height;

    # taller
    if ($height > $max_height) {
        $width = ($max_height / $height) * $width;
        $height = $max_height;
    }

    # wider
    if ($width > $max_width) {
        $height = ($max_width / $width) * $height;
        $width = $max_width;
    }

    $image_p = imagecreatetruecolor($width, $height);

    $image = imagecreatefromjpeg($filename);

    imagecopyresampled($image_p, $image, 0, 0, 0, 0,
                                     $width, $height, $orig_width, $orig_height);

    imagejpeg($image_p, 'tartuffe.jpg');									 
									 
    return $image_p;
}

$myimage = resizeImage('test.jpg', '150', '120');


?>