|
Posted by Philip Hallstrom on 10/05/23 11:13
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);
> }
>
Navigation:
[Reply to this message]
|