Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHImageManager fetch full size image [duplicate]

I have this function to fetch images from assets:

func fetchImage(asset: PhotoAsset, size: CGSize, resizeMode: ResizeMode = .Exact, completion: (result: UIImage?) -> Void) {
        let photoAsset = asset as! PHAsset
        var options: PHImageRequestOptions?
        switch resizeMode {
            case .Exact:
                options = PHImageRequestOptions()
                options?.resizeMode = .Exact
            case .Default:
                options = nil
        }
        manager.requestImageForAsset(
            photoAsset,
            targetSize: size,
            contentMode: .AspectFill,
            options: options
        ) { [weak self] result, _ in
            completion(result: result)
        }
    }

but how can I denfine to fetch the original size image?

Thank you!

like image 942
F.SO3 Avatar asked Jun 17 '16 08:06

F.SO3


1 Answers

Use PHImageManagerMaximumSize for targetSize:

func fetchImage(asset: PhotoAsset, size: CGSize, resizeMode: ResizeMode = .Exact, completion: (result: UIImage?) -> Void) {
        let photoAsset = asset as! PHAsset
        var options: PHImageRequestOptions?
        switch resizeMode {
            case .Exact:
                options = PHImageRequestOptions()
                options?.resizeMode = .Exact
            case .Default:
                options = nil
        }
        manager.requestImageForAsset(
            photoAsset,
            targetSize: PHImageManagerMaximumSize,
            contentMode: .AspectFill,
            options: options
        ) { [weak self] result, _ in
            completion(result: result)
        }
    }
like image 57
Thomas Avatar answered Nov 03 '22 02:11

Thomas