Giter VIP home page Giter VIP logo

Comments (7)

zhangao0086 avatar zhangao0086 commented on May 27, 2024 2

Hi all, first of all I'm sorry for the late response...

In the latest version, I've optimized for fetching original image. I think I've solved the crash issue.
(You can try to selecting 50 photos 😃 )

And I've add an API to fetch image with contentModel:

public func fetchImageWithSize(size: CGSize, options: PHImageRequestOptions?, contentMode: PHImageContentMode, completeBlock: (image: UIImage?, info: [NSObject : AnyObject]?) -> Void)

By default, the fetchImageWithSize method fetching image with .AspectFit.

Let me know if you have any questions :)

from dkimagepickercontroller.

aldolazuardi avatar aldolazuardi commented on May 27, 2024 1

(kinda) found the solution. I changed func in fetchOriginalImage in DKAsset from

getImageManager().fetchImageForAsset(self, size: PHImageManagerMaximumSize, options: options) to getImageManager().fetchImageForAsset(self, size: CGSize(width: 1500, height: 1500), contentMode: .AspectFit) it keeps the ratio with 1500px maximum pixel

from dkimagepickercontroller.

zhiyanshao avatar zhiyanshao commented on May 27, 2024

Actually I used fetchFullScreenImage instead which keeps the original ratio and is much faster than fetchOriginalImage

from dkimagepickercontroller.

aldolazuardi avatar aldolazuardi commented on May 27, 2024

@zhangao0086 First of all i want to say thank you for such a great library! but i want to ask same question, how to keep the ratio with fetchImageWithSize? when i use fetchOriginalImage app would crash but if im using fetchFullscreenImage its too small.

from dkimagepickercontroller.

atongmu518 avatar atongmu518 commented on May 27, 2024

I can get it :

asset.fetchOriginalImageWithCompleteBlock({ (image, info) in
    let width: CGFloat = image!.size.width
    let height: CGFloat = image!.size.height

    let realWidth: CGFloat = 740  //the max width
    var realHeight: CGFloat = 0
    if width < realWidth {
        realHeight = height
    } else {
        realHeight = realWidth * height / width
    }

    asset.fetchImageWithSize(CGSizeMake(realWidth, realHeight), completeBlock: { (image, info) in
        if let uploadImag  = image { // this is the image I wanted

         }
    })
})

from dkimagepickercontroller.

zhiyanshao avatar zhiyanshao commented on May 27, 2024

@atongmu518 so basically you get the images twice. I think it may still crash if you select too many photos. For me, it crashed after selecting 6 or more on iphone 6 plus.

from dkimagepickercontroller.

atongmu518 avatar atongmu518 commented on May 27, 2024

@zhiyanshao
another solution is extension the DKAsset, just like @aldolazuardi said, it works!

extension DKAsset {
    func fetchImageForAssetKeepRatio(size:CGSize, completeBlock: (image: UIImage?, info: [NSObject : AnyObject]?) -> Void) {
        getImageManager().fetchImageForAsset(self, size:size , contentMode: .AspectFit) { (image, info) in
            completeBlock(image: image, info: info)
        }
    }
}

maybe it crashed after selecting 12. haha

from dkimagepickercontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.