Comments (7)
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.
(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.
Actually I used fetchFullScreenImage instead which keeps the original ratio and is much faster than fetchOriginalImage
from dkimagepickercontroller.
@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.
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.
@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.
@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)
- adding Ukrainian localization (uk)
- How to display overlay image on camera
- ios 14.6 not getting all the selected images HOT 1
- How to change color of selected images HOT 6
- Top picker bar is transparent in iOS15
- Camera icon not showing when deploying in xcode13 HOT 3
- Localization not working
- Compilation error: "LLVM ERROR: out of memory" HOT 11
- Xcode 13.3 - Error (Xcode): Segmentation fault: 11 Encountered error while archiving for device. HOT 35
- Crash on DKCamera.captureImage function HOT 1
- How to get original files URLs?
- Xcode 14: Swift Compiler Error: Stored properties cannot be marked potentially unavailable with '@available' HOT 4
- ios error Signing for "DKImagePickerController-DKImagePickerController" requires a development team. HOT 14
- After changing to 4.3.4, Now i cant compile with BITCODE enabled HOT 4
- XCode 14 Build error: Stored properties cannot be marked potentially unavailable with '@available' HOT 16
- I want to export the video to .mp4
- xcode14中不兼容ios12系统
- No Actions when clicking in Camera Icon, it should open camera to capture
- How to perform Multiple Image selection but only single video selection
- Xcode 13 升级 14后,运行到真机没有问题但是打包会报错 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkimagepickercontroller.