note 33338 deleted from function.imagerotate by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 06:58:34 +0000 |
| Subject: | note 33338 deleted from function.imagerotate by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77880@lists.php.net to get a copy of this message | ||
Note Submitter: allrite
----
The following code resizes the outputted image to fit the rotation.
<?php
Header("Content-type: image/jpeg");
$filename = "filename.jpg";
$img_size = getImageSize($filename);
$x = $img_size[0];
$y = $img_size[1];
if ($x > $y)
{
$newd = $x;
}
else
{
$newd = $y;
}
$src_img = ImageCreateFromJPEG($filename);
$dst_img = ImageCreateTrueColor($newd,$newd);
$final_img = ImageCreateTrueColor($y,$x);
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$x,$y,$x,$y);
$degrees = "90";
$rotated_img = ImageRotate($dst_img,$degrees,0);
ImageCopyResampled($final_img,$rotated_img,0,0,0,0,$y,$x,$y,$x);
ImageJPEG($final_img);
?>