简体   繁体   English

如何获取PHAsset中的图像类型(PNG或JPG)?

[英]How to get image Type In PHAsset(PNG or JPG)?

In iOS8 and later, i get images at this code: 在iOS8及更高版本中,我通过以下代码获取图像:

    PHFetchOptions *option = [[PHFetchOptions alloc] init];
    option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
    PHFetchResult *result = [PHAsset fetchAssetsInAssetCollection:_collection options:option];

    [result enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if (((PHAsset *)obj).mediaType == PHAssetMediaTypeImage) {

            PHCachingImageManager *imageManager = [[PHCachingImageManager alloc] init];
            PHAsset *asset = obj;
            PHImageRequestOptions * options = [[PHImageRequestOptions alloc] init];
            options.networkAccessAllowed = YES;
            options.synchronous = YES;


            [imageManager requestImageDataForAsset:asset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
                /*******/
                /* Now I get image type in here with imageDate*/
                /* I just want JPG type Image*/
            }];
        }
    }];

But in this code, I need a lot of time, So how can I get Image Type with PHAsset and don't use requestImageData 但是在这段代码中,我需要很多时间,所以如何使用PHAsset获取图像类型并且不使用requestImageData

据我所知,您无法通过PHAsset获取图像类型,但是可以通过CIImage的属性properties(properties是属性的名称)来获取

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从PHAsset获取原始图像和媒体类型? - How to get Original Image and media type from PHAsset? 如何知道这个图像是jpg或png iphone - how to know this image is jpg or png iphone 如何从PHAsset获取图像URL? 是否可以使用PHAsset URL保存图像以记录目录? - How To get Image URL From PHAsset? Is it possible To save Image using PHAsset URL to document Directory? 如何在iOS中使用PHAsset获取图像的纬度和经度? - How to get latitude and longitude of an image using PHAsset in iOS? 如何从iOS扩展程序中的图像URL获取对PHAsset的引用? - How to get a reference to the PHAsset from an image URL in the iOS Extension? iOS Swift 4:从didFinishPickingMediaWithInfo获取图像格式(JPG,PNG,GIF) - iOS Swift 4: Get Image Format (JPG,PNG,GIF) From didFinishPickingMediaWithInfo 保存到照片库后如何获取图像的PHAsset? - How to get PHAsset of image after saving it to photos libary? 将Dicom图像转换为jpg,png - Convert Dicom image to to jpg,png 如何在ios的ftp服务器上上传.png或.jpg图像? - How to upload image either .png or .jpg on ftp server in ios.? 如何将.cpbitmap转换为可读图像(png,jpg,jpeg…) - How to convert .cpbitmap to readable image (png, jpg, jpeg…)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM