【问题标题】:PHIMageManager requestImageDataForAsset:options:resultHandler: does not take into account orientationPHIMageManager requestImageDataForAsset:options:resultHandler: 不考虑方向
【发布时间】:2016-09-06 16:18:31
【问题描述】:

我正在尝试使用此方法将 imageData 上传到我的服务,但生成的 imageData 没有考虑方向,我正在以不正确的方向上传图像。

有什么建议吗?

【问题讨论】:

    标签: ios alasset phasset


    【解决方案1】:

    我使用这个 f° 解决了完全相同的问题,要获得原始图像大小,您只需传递 size == CGSizeMake (10000000000, 10000000000),希望对您有所帮助:)

    + (UIImage *)createThumbFromImageIO:(UIImage*)image maxPixelSize:(CGSize)size
    {
        NSData *imagedata = UIImageJPEGRepresentation(image, 1);
        CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imagedata, NULL);
    
        if (!imageSource) return nil;
    
        CGSize imageSize = image.size;
    
        imageSize = CGSizeMake(size.width,size.height);
    
        CFDictionaryRef options = (__bridge CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
                                                             (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
                                                             (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
                                                             (id)[NSNumber numberWithFloat:imageSize.height], (id)kCGImageSourceThumbnailMaxPixelSize,
                                                             nil];
    
        CGImageRef imgRef = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options);
    
        image = [UIImage imageWithCGImage:imgRef];
    
        CGImageRelease(imgRef);
    
        CFRelease(imageSource);
        return image;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-19
      • 2016-01-12
      • 2023-04-03
      • 1970-01-01
      • 2015-10-13
      相关资源
      最近更新 更多