我正试着在我的网站上放一个旋转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";
}
?>它将此内容粘贴到页面上:
JPEG : gd-jpeg v1.0 (使用IJG JPEG v62),默认质量?C$。‘",#(7),01444’9=82<.342?C v62??}!1AQa“Q2‘”#B?$3br,%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ?w!1Aqaq“2B’?#3R?br- $4á(并持续很长一段时间)
如果我将其更改为顺时针方向,那么胡言乱语也会发生变化,所以我认为它在某种程度上是有效的,但它不会从它创建一个jpg。任何帮助都是很棒的。
发布于 2012-09-21 16:08:17
这就是图像。您只是没有告诉您的浏览器它是,您的浏览器将数据解释为文本。设置一个标题,告诉浏览器将数据解释为图像:
header('Content-Type: image/jpeg');图像数据将必须是页面上唯一输出的东西,在它之前或之后没有其他HTML或文本。
https://stackoverflow.com/questions/12526541
复制相似问题