谁能帮我解决这个错误?

Can anyone please help me in resolving this error?

我的代码:

      <!DOCTYPE html>
        <html>
        <body>

        <h1>Rotating an Image</h1>

        <?php

        $img = imagecreatefromjpeg("myPic.jpg");
        $imgRotated = imagerotate($img, 45, -1);
        imagejpeg($imgRotated, "myPic.jpg", 100);
        ?>
        <img src="myPic.jpg"/><img src="myPicRotated.jpg">

        </body>
        </html>

错误

Warning: imagejpeg() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\MyWebsite\index.php on line 11

您对 imagerotate 的调用不成功并且 returns false - 请参阅文档。

这就是 imagejpeg 抱怨的原因。

你可以改成

$imgRotated = imagerotate($img, 45, 0);

哪个效果更好。