/    Sign up×
Community /Pin to ProfileBookmark

Image Rotate problem

Trying to do my first “image rotation” and not having success. Got these pics from a friend and one of them needs to be turned 90 degrees. I found this logic online and am trying to make it work.
Went thru the process of ensuring that I had enough memory and am doing error checking as I progress but the end result, a second image file, is not rotated. Here it is:

[code]
$srcname = $root.$filename;
echo “Reading image<br>$srcname<br>”;
$source = imagecreatefromjpeg($srcname);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
echo “Rotated $degrees degrees<br>”;
if (imagejpeg($source, $root.$savename))
echo “Saved as:<br>$root$savename”;
else
echo “Could not save new image<br>$root$savename<br>”;
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
exit();
[/code]

The filename shows up correctly in my echos and the degrees is set to 270 (docs tell me that the rotate is anti-clockwise so while I only need to go 90 to the right I am going 270 to the left). The save image name is also correct but when I view the new image it is not rotated.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmauthorFeb 26.2020 — So silly. Missed a very simple thing here.

All fixed!! Missed a variable name in the save process. Was saving the un-rotated image apparently.
Copy linkTweet thisAlerts:
@VITSUSAFeb 29.2020 — @ginerjm#1615326 Click on the mentioned hyperlink to know about solution of Image Rotate problem-

https://www.youtube.com/watch?v=wbWCqSmQwkE

https://www.magictoolbox.com/magic360/examples/
Copy linkTweet thisAlerts:
@ginerjmauthorFeb 29.2020 — Thanks for the response, but as you should note I found my typo shortly after posting.
×

Success!

Help @ginerjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...