TZImageManager.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // TZImageManager.h
  3. // TZImagePickerController
  4. //
  5. // Created by 谭真 on 16/1/4.
  6. // Copyright © 2016年 谭真. All rights reserved.
  7. // 图片资源获取管理类
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import <AVFoundation/AVFoundation.h>
  11. #import <Photos/Photos.h>
  12. @class TZAlbumModel,TZAssetModel;
  13. @interface TZImageManager : NSObject
  14. @property (nonatomic, strong) PHCachingImageManager *cachingImageManager;
  15. + (instancetype)manager;
  16. @property (nonatomic, assign) BOOL shouldFixOrientation;
  17. /// Default is 600px / 默认600像素宽
  18. @property (nonatomic, assign) CGFloat photoPreviewMaxWidth;
  19. /// Default is 4, Use in photos collectionView in TZPhotoPickerController
  20. /// 默认4列, TZPhotoPickerController中的照片collectionView
  21. @property (nonatomic, assign) NSInteger columnNumber;
  22. /// Sort photos ascending by modificationDate,Default is YES
  23. /// 对照片排序,按修改时间升序,默认是YES。如果设置为NO,最新的照片会显示在最前面,内部的拍照按钮会排在第一个
  24. @property (nonatomic, assign) BOOL sortAscendingByModificationDate;
  25. /// Minimum selectable photo width, Default is 0
  26. /// 最小可选中的图片宽度,默认是0,小于这个宽度的图片不可选中
  27. @property (nonatomic, assign) NSInteger minPhotoWidthSelectable;
  28. @property (nonatomic, assign) NSInteger minPhotoHeightSelectable;
  29. @property (nonatomic, assign) BOOL hideWhenCanNotSelect;
  30. /// Return YES if Authorized 返回YES如果得到了授权
  31. - (BOOL)authorizationStatusAuthorized;
  32. - (NSInteger)authorizationStatus;
  33. /// Get Album 获得相册/相册数组
  34. - (void)getCameraRollAlbum:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(TZAlbumModel *model))completion;
  35. - (void)getAllAlbums:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(NSArray<TZAlbumModel *> *models))completion;
  36. /// Get Assets 获得Asset数组
  37. - (void)getAssetsFromFetchResult:(id)result allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(NSArray<TZAssetModel *> *models))completion;
  38. - (void)getAssetFromFetchResult:(id)result atIndex:(NSInteger)index allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(TZAssetModel *model))completion;
  39. /// Get photo 获得照片
  40. - (void)getPostImageWithAlbumModel:(TZAlbumModel *)model completion:(void (^)(UIImage *postImage))completion;
  41. - (PHImageRequestID)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
  42. - (PHImageRequestID)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
  43. - (PHImageRequestID)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
  44. - (PHImageRequestID)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
  45. /// Get full Image 获取原图
  46. /// 该方法会先返回缩略图,再返回原图,如果info[PHImageResultIsDegradedKey] 为 YES,则表明当前返回的是缩略图,否则是原图。
  47. - (void)getOriginalPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion;
  48. - (void)getOriginalPhotoWithAsset:(id)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
  49. - (void)getOriginalPhotoDataWithAsset:(id)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
  50. /// Save photo 保存照片
  51. - (void)savePhotoWithImage:(UIImage *)image completion:(void (^)(NSError *error))completion;
  52. /// Get video 获得视频
  53. - (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion;
  54. /// Export video 导出视频
  55. - (void)getVideoOutputPathWithAsset:(id)asset completion:(void (^)(NSString *outputPath))completion;
  56. /// Get photo bytes 获得一组照片的大小
  57. - (void)getPhotosBytesWithArray:(NSArray *)photos completion:(void (^)(NSString *totalBytes))completion;
  58. /// Judge is a assets array contain the asset 判断一个assets数组是否包含这个asset
  59. - (BOOL)isAssetsArray:(NSArray *)assets containAsset:(id)asset;
  60. - (NSString *)getAssetIdentifier:(id)asset;
  61. - (BOOL)isCameraRollAlbum:(NSString *)albumName;
  62. /// 检查照片大小是否满足最小要求
  63. - (BOOL)isPhotoSelectableWithAsset:(id)asset;
  64. - (CGSize)photoSizeWithAsset:(id)asset;
  65. /// 修正图片转向
  66. - (UIImage *)fixOrientation:(UIImage *)aImage;
  67. @end
  68. //@interface TZSortDescriptor : NSSortDescriptor
  69. //
  70. //@end