Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJAKZ AIZZAT
7,813 PointsWhy I can't output the image in rotate?
<?php
$img = imagecreatefromjpeg('simpletext.jpg');
$imgRotated = imagerotate($img, 45,-1);
imagejpeg($imgRotated,'newsimpletext.jpg',100);
?>
<img src="simpletext.jpg" />
<hr>
<img sec="newsimpletext.jpg" />
I want to output the image in rotate version but it has error
Warning: imagejpeg() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\developphp\index.php on line 6
2 Answers
Aimee Ault
29,193 Pointsimagerotate actually will return to you a boolean (false) if it fails, so the problem is likely either there or in setting the initial $img. Are you sure it's loading an image into that variable?
JAKZ AIZZAT
7,813 PointsI have tried with other image and its still doesn't work. :(
This is its error: Warning: imagejpeg() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\developphp\index.php
JAKZ AIZZAT
7,813 PointsJAKZ AIZZAT
7,813 PointsYa. Im sure. Im trying to echo the original image at bottom of line code and its work.
Actually i'm following this tutorial : http://www.developphp.com/view.php?tid=1138
Aimee Ault
29,193 PointsAimee Ault
29,193 PointsHave you tried it with a different jpeg image? I just tried your code out and it works for me. Do you see any errors in your error_log for the call to imagerotate?