Get Image Orientation and rotate as per orientation

前端 未结 3 1549
后悔当初
后悔当初 2020-11-27 16:29

having problem in getting image orientation with below code

    string fileName = @\"D:\\...\\...\\01012015004435.jpeg\";

    int rotate = 0;
    using (var         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 17:14

    Use the following:

    • img.PropertyIdList.Contains(orientationId) to check if the Exif tag is present.
    • img.GetPropertyItem(orientationId) to get it (after the above check, otherwise you'll get an ArgumentException).
    • img.SetPropertyItem(pItem) to set it.

    I wrote a simple helper class that does all that: you can check the full source code here.

    Other info and a quick case-study is also available on the following post on my blog:

    Change image orientation for iPhone and/or Android pics in NET C#

提交回复
热议问题