deepak kumar deepak kumar - 10 days ago 5
iOS Question

image rotated 90 degree after loaded from url in iOS?

I have an

UIImageView
.I am loading image on that imageview from a url.Now after image is loaded it gets roatated 90 degree.When i open image url on webbrowser then it works fine.Please sugesst how can i remove this issue.I am using below code for it

imageView.sd_setImage(with: URL(string: url), placeholderImage:UIImage(named:"image_icon"))


Note:I am using sdwebimage for loading image from url

Answer

Your image is carrying EXIF data. I guess you are getting data to upload using UIImageJPEGRepresentation which includes orientation information. Try using UIImagePNGRepresentation because png images does not carry orientation information. I had the same problem earlier. Try and reply if works.