简体   繁体   中英

How to save .jpeg/.tiff image into device gallery in iOS

I want to save my .jpeg and .tiff image with custom album into the gallery of device.

So I have refer this answer for saving an image with custom album into the gallery.

let myImage = UIImage.init(named: "image.tiff")
self.createAlbum(myImage!) //This method is taken from above linked answer

But it saves image into .jpg format always.

Also I am trying to save image with default album using this answer . But it also saves image into .jpg format.

I have read several posts here about saving image into gallery. Unfortunately, it seems that there is not any "good" solution.

When I saved my image into the document directory. It saved with right format. But When I am trying to save this image into device gallery, then it always saves into .jpg format.

Is there any other way to save image with custom name into the custom album in gallery..?

I want to save my .jpeg image and .tiff image into gallery of device.

Any help would be appreciated.

Can Save Image using following code

import AssetsLibrary


let image = NSData(contentsOfURL: url)  
//or let image = UIImage.init(named: "image.tiff")

ALAssetsLibrary().writeImageDataToSavedPhotosAlbum(image, metadata: nil, completionBlock: { (assetURL: NSURL!, error: NSError!) -> Void in
        print(assetURL)
})

But apple stores it by default JPG Format. You are not able to change it. It Totally managed by Apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM