- (UIImage *)transformImage:(UIImage *)image  {
    
    if (image.imageOrientation == UIImageOrientationUp) { return image; }
    
    UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
    [image drawInRect:(CGRect){0, 0, image.size}];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}
Copy the code