Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

没有返回原图——关于获取原图的方法 #457

Closed
asjy-live opened this issue May 15, 2017 · 3 comments
Closed

没有返回原图——关于获取原图的方法 #457

asjy-live opened this issue May 15, 2017 · 3 comments

Comments

@asjy-live
Copy link

asjy-live commented May 15, 2017

1、拍照返回来的asset和photo单张照片都是原图,应该photo是压缩图,asset是原图的。
2、通过选取照片后,// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:],我看您说先返回缩略图,再返回原图 ,应该在吊起拍照的时候 去设置 是返回原图还是缩略图。
/// Get full Image 获取原图
/// 该方法会先返回缩略图,再返回原图,如果info[PHImageResultIsDegradedKey] 为 YES,则表明当前返回的是缩略图,否则是原图。 这个 也不对。 我只得到了原图。

备注:
目前这两个问题,我都是拿出来 自己去规避了。希望demo内部可以直接在返回的时候就规避掉。
小弟qq邮箱 [email protected]。希望可以联系解决

@banchichen
Copy link
Owner

banchichen commented Jun 2, 2017

你好,

  1. 返回的photo是UIImage对象,直接用于显示;asset是PHAsset或者ALAsset对象,用于获取照片的其他所有信息(原图、创建时间、修改时间、经纬度、文件名字、图片类型、图片路径等等信息...)
  2. 即使设置了可以选择原图,用户也选择了原图,选择器也不会直接返回你原图,一张原图大小一般2-3M,如果选了多张内存会暴涨,所以返回的photo都是缩略图(适合iPhone尺寸的),要原图需要通过asset去获取。
  3. [[TZImageManager manager] getOriginalPhotoWithAsset:completion:] 内部走的是系统方法去获取原图,一般会先返回缩略图,再返回原图。我之前描述不够准确,抱歉,目前已更新描述。

具体什么时候会先返回缩略图,苹果的解释是这样的:

// If the asset's aspect ratio does not match that of the given targetSize, contentMode determines how the image will be resized.
// PHImageContentModeAspectFit: Fit the asked size by maintaining the aspect ratio, the delivered image may not necessarily be the asked targetSize (see PHImageRequestOptionsDeliveryMode and PHImageRequestOptionsResizeMode)
// PHImageContentModeAspectFill: Fill the asked size, some portion of the content may be clipped, the delivered image may not necessarily be the asked targetSize (see PHImageRequestOptionsDeliveryMode && PHImageRequestOptionsResizeMode)
// PHImageContentModeDefault: Use PHImageContentModeDefault when size is PHImageManagerMaximumSize (though no scaling/cropping will be done on the result)
// If -[PHImageRequestOptions isSynchronous] returns NO (or options is nil), resultHandler may be called 1 or more times.
// Typically in this case, resultHandler will be called asynchronously on the main thread with the requested results.
// However, if deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic, resultHandler may be called synchronously on the calling thread if any image data is immediately available. If the image data returned in this first pass is of insufficient quality, resultHandler will be called again, asychronously on the main thread at a later time with the "correct" results.
// If the request is cancelled, resultHandler may not be called at all.
// If -[PHImageRequestOptions isSynchronous] returns YES, resultHandler will be called exactly once, synchronously and on the calling thread. Synchronous requests cannot be cancelled.
// resultHandler for asynchronous requests, always called on main thread

  • (PHImageRequestID)requestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(nullable PHImageRequestOptions *)options resultHandler:(void (^)(UIImage *__nullable result, NSDictionary *__nullable info))resultHandler;

@banchichen banchichen changed the title 在使用过程中发现的问题 在使用过程中发现的问题——关于获取原图的方法 Jun 2, 2017
@banchichen banchichen changed the title 在使用过程中发现的问题——关于获取原图的方法 没有返回原图——关于获取原图的方法 Jun 3, 2017
@raodaye
Copy link

raodaye commented Oct 26, 2020

这个方法能直接拿到图片的路径吗

@banchichen
Copy link
Owner

@raodaye 要路径的话,需要自己保存到沙盒,使用沙盒路径

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants