Log in

View Full Version : how can i rotate an image file to 270 degrees or 90 degrees in clockwise?


UFOxyz
18th December 2024, 04:44
how can i rotate an image file to 270 degrees or 90 degrees in clockwise?

none of these below worked.
ffmpeg -y -rotate=90 -i "%1" "m:\aaa.bmp"
ffmpeg -y -rotate=90 -i "%~1" "m:\aaa.bmp"
ffmpeg -y -display_rotation 90 -i b.bmp "m:\aaa.bmp"
ffmpeg -y -display_rotation 90 -codec copy -i b.bmp "m:\aaa.bmp"


are these in below the same?
-c copy
-codec copy
-c codec copy
*************************


PS
now i kind of got it after a long floundering
-codec copy must not be included

ffmpeg -y -display_rotation 270 -i "%1" output2.bmp
if there is a way to improve or refine the command line, please do add

microchip8
18th December 2024, 13:42
You cannot use -c copy since it does unmodified stream copy. If you rotate, that's a modification. As the name implies, it copies content 1:1, hence the name copy. If you modify something, it's no longer "copy" and it won't work.

To rotate 90° clockwise, use -vf transpose=1

Z2697
18th December 2024, 18:50
hflip or vflip should be used after transpose to create actual rotation effect. There's also a filter that's just called "rotate".

microchip8
18th December 2024, 19:54
Not mandatory. Just using transpose=<value> rotates just fine.

Sharc
19th December 2024, 20:24
Something like this?
ffplay -i "your_source" -vf "rotate='15*PI/180:ow=hypot(iw,ih):oh=ow',scale=w=-2:h=576,setsar=1/1"

or
ffmpeg -i "your_source" -vf "rotate='0.2*PI*t:ow=hypot(iw,ih):oh=ow:fillcolor=yellow',scale=w=-2:h=720,setsar=sar=1/1" -c:a copy -c:v libx264 -crf 20 "rotated.mp4"

StainlessS
19th December 2024, 23:41
Maybe see this (Open Source, I think), Lossless rotate for jpg, apparently.
FreeVimager
https://www.contaware.com/software/freevimager.html