$filename = '01.jpg';
$degrees = 90;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
$rotate = imagejpeg($rotate);
我正在使用此请解释如何更新这些图像
答案 0 :(得分:1)
imagejpeg
- 将图像输出到浏览器或文件。将要保存文件的图像路径作为第二个参数传递。
参考:http://php.net/manual/en/function.imagejpeg.php
$filename = '01.jpg';
$degrees = 90;
$source = imagecreatefromjpeg($filename);
$rotate = imagerotate($source, $degrees, 0);
imagejpeg($rotate, $filename);
答案 1 :(得分:1)
请使用以下代码
function RotateImg($filename = '',$angle = 0,$savename = false)
{
$original = imagecreatefromjpeg($filename);
$rotated = imagerotate($original, $angle, 0);
if($savename == false) {
header('Content-Type: image/jpeg');
imagejpeg($rotated);
}
else {
imagejpeg($rotated,$savename);
}
imagedestroy($rotated);
}
$filename = 'http://images.all-free-download.com/images/graphiclarge/beautiful_nature_landscape_02_hd_picture_166206.jpg';
$saveto = $_SERVER['DOCUMENT_ROOT']."/images/test.jpg";
RotateImg($filename,90,$saveto);