Re: image calculation problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



see below...

Basically I am trying to make a thumb where the width is 87px...I dont care what the height is, heres the code:

function prop_thumb_height()
{
// The file
$filename = 'cat.jpg';

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

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);


$width = 87;

// note I'm not checking if $width_orig == 0
$scale_by = $width / $width_orig;

$height = floor($height_orig * $scale_by + 0.5);

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

// Output
imagejpeg($image_p, 'ryan.jpg', 100);
}


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux