在PHP中使用imagerotate()
旋转图像后,如何获得图像的宽度和高度?
这是我的代码:
<?php
// File and rotation
$filename = 'test.jpg';
$degrees = 180;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
imagejpeg($rotate);
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
?>
但在输出之前,我想做的是,我想得到旋转图像的宽度和高度。我该怎么做?
我相信你可以做类似的事情:
$data = getimagesize($filename);
$width = $data[0];
$height = $data[1];
另一种选择是:
list($width, $height) = getimagesize($filename);
$width = imagesx($rotate);
$height = imagesy($rotate);
相反。