【发布时间】:2016-09-06 16:18:31
【问题描述】:
我正在尝试使用此方法将 imageData 上传到我的服务,但生成的 imageData 没有考虑方向,我正在以不正确的方向上传图像。
有什么建议吗?
【问题讨论】:
我正在尝试使用此方法将 imageData 上传到我的服务,但生成的 imageData 没有考虑方向,我正在以不正确的方向上传图像。
有什么建议吗?
【问题讨论】:
我使用这个 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;
}
【讨论】: