我試圖把一個旋轉IMG功能在我的網站。我正在使用imagejpeg(),但它返回一個滿是亂碼的斯諾。你能解釋爲什麼嗎?PHP imagejpeg()
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ÿþ> CREATOR:GD-JPEG V1.0(使用IJG JPEG V62),默認畫質下YUC $「。 」,#(7),01444'9 = 82 <.342ÿÛC2 !!22222222222222222222222222222222222222222222222222ÿÀûÛ 「雅ÿÄμ} 1AQa」 q2'¡#乙±ARND $ 3房,%&「()* 456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ「!...†‡ ‰S'‘’•--~™的¢¤£¥|§¨©ª²³'μ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄÿÄμw!1AQaq「2B'¡±A#$3RðbrÑ4A(和和FOR A很長的路要走)
如果我把它改爲順時針亂碼的變化一樣,所以我覺得它的工作有點,但它不是從創建它的JPG。任何幫助都是極好的。
在輸出前添加:header('content-type:image/jpeg')。 – Teson
@ user247245正好! – Wh1T3h4Ck5