Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to rotate image -90 degree

I am using rotateflip to rotate image and also save on server here is the code:

using (Image image = Image.FromFile(HttpContext.Current.Server.MapPath("~/Content/Job_Files/" + Job_ID + "/" + new_str + "/Images/" + path)))
{
    //rotate the picture by 90 degrees and re-save the picture as a Jpeg
    if (cbox_id == "cboxRight")
    {
        image.RotateFlip(RotateFlipType.Rotate90FlipNone);
    }
    else
    {
        image.RotateFlip(RotateFlipType.Rotate90FlipNone);
    }
    image.Save(new_path, System.Drawing.Imaging.ImageFormat.Jpeg);
    image.Dispose();
}

Image is rotated at right side on click of rotate right but not working on left rotate..how to rotate it??

like image 641
Dhara Avatar asked Oct 26 '25 02:10

Dhara


2 Answers

Both forks of your if statement contain the line:

image.RotateFlip(RotateFlipType.Rotate90FlipNone);

so, unless there's some serious magic going on, they'll both do exactly the same thing.

One of them should probably be:

image.RotateFlip(RotateFlipType.Rotate270FlipNone);

(rotation is always clockwise, so rotating 270 is identical to rotating -90).

like image 104
paxdiablo Avatar answered Oct 27 '25 16:10

paxdiablo


Rotating 270 degrees clockwise is the same as rotating 90 degrees anticlockwise. so Use RotateFlipType.Rotate270FlipXor RotateFlipType.Rotate270FlipNone

Update: The provided options may be used as required.

like image 25
Tushar Avatar answered Oct 27 '25 17:10

Tushar