Can anyone please help me in resolving this error?

59 Views Asked by At

My Code:

      <!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>

Error

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

There are 1 best solutions below

0
On BEST ANSWER

Your call to imagerotate is unsuccessful and returns false - see documentation.

That's why imagejpeg complains about it.

You can change it to

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

which should work better.