How to convert all image format into .png format?

前端 未结 2 2071
遇见更好的自我
遇见更好的自我 2020-12-18 13:02

I am making a small application where I am receiving images from web-service. I am getting the image url. And the format of images is different different like .jpg,.gif,.png

相关标签:
2条回答
  • 2020-12-18 13:46

    after you retrieve your images/url save them this way:

    NSData *imageData = UIImagePNGRepresentation(image);
    [imageData writeToFile:savedImagePath atomically:YES];
    
    0 讨论(0)
  • 2020-12-18 13:54

    Would it not be easier if you use an image library like SDWebImage which handles all the asynchronous image downloading and caching of the image onto your device?

    https://github.com/rs/SDWebImage

    Then you can do something like:

    [myImageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
                       placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    
    0 讨论(0)
提交回复
热议问题