【发布时间】:2012-09-21 08:04:27
【问题描述】:
我正在尝试在我的网站上添加旋转 img 功能。我正在使用 imagejpeg() 但它返回一个充满胡言乱语的 sloo。你能解释一下为什么吗?
if ($_GET["rotate"] == "clockwise")
{
$degrees = 90;
// Content type
//header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($path);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
if (imagejpeg($rotate))
echo "Your image has been rotated clockwise";
}
if ($_GET["rotate"] == "counterclockwise")
{
$degrees = 270;
// Content type
//header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($path);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
if (imagejpeg($rotate))
echo "Your image has been rotated Counterclockwise";
}
?>
它将这个粘贴到页面上:
ÿØÿàJFIFÿþ>创建者:gd-jpeg v1.0(使用 IJG JPEG v62),默认质量 ÿÛC $。 ",#(7),01444'9=82<.342 on and for a>
如果我将其更改为顺时针,乱码也会发生变化,所以我认为它有点工作,但它不会从中创建 jpg。任何帮助都是极好的。
【问题讨论】:
-
在输出前添加:header('content-type:image/jpeg')。
标签: php