Ios 为什么PHImageManager.default().requestImage返回;“裁剪”;调整大小模式为时的图像。精确且目标大小为原始图像大小的5%?
我的要求是调整原始图像的大小为其原始大小的5%,而不进行裁剪。假设图像为(1000x1000),调整大小的图像应为(50x50) 下面附上的代码片段有助于您理解我的流程结构。 多谢各位 注意:我不想使用CGContext,因为我有大量的图像要在短时间内调整大小 根据我使用的文件。精确调整大小模式,我得到50x50图像,但中心裁剪Ios 为什么PHImageManager.default().requestImage返回;“裁剪”;调整大小模式为时的图像。精确且目标大小为原始图像大小的5%?,ios,swift,xcode,image-resizing,ios13,Ios,Swift,Xcode,Image Resizing,Ios13,我的要求是调整原始图像的大小为其原始大小的5%,而不进行裁剪。假设图像为(1000x1000),调整大小的图像应为(50x50) 下面附上的代码片段有助于您理解我的流程结构。 多谢各位 注意:我不想使用CGContext,因为我有大量的图像要在短时间内调整大小 根据我使用的文件。精确调整大小模式,我得到50x50图像,但中心裁剪 // Asset has original image with (1000x1000) // imageSize is CGSize(width:5
// Asset has original image with (1000x1000)
// imageSize is CGSize(width:50,height:50)
let options = PHImageRequestOptions()
options.resizeMode = .exact
//options.normalizedCropRect = CGRect.zero
options.deliveryMode = .highQualityFormat
options.isSynchronous = true
options.isNetworkAccessAllowed = true
PHImageManager.default().requestImage(for: asset, targetSize: imageSize, contentMode: .aspectFill, options: options, resultHandler: {(resultImage, info) in
// resultImage.size is (50x50) with centerCropped
})
删除
options.isSynchronous=true
。这能解决问题吗?或者将模式更改为aspectFit。这有帮助吗?还有“中间裁剪”是什么意思?你能发布一张结果的图片吗?是的,同步错误和内容模式方面适合结合在一起对我有效。感谢@matt节省时间。删除options.isSynchronous=true
。这能解决问题吗?或者将模式更改为aspectFit。这有帮助吗?还有“中间裁剪”是什么意思?你能发布一张结果的图片吗?是的,同步错误和内容模式方面适合结合在一起对我有效。谢谢@matt为您节省时间。