为什么第一个 JPEG 图像的字节是第二个的 1/4?
[_stillOutput captureStillImageAsynchronouslyFromConnection:videoConnection:videoConnection completionHandler:
^(CMSampleBufferRef imageSampleBuffer, NSError * error)
{
NSData* imageBytes = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
NSLog(@"Size = %ld", imageBytes.length);
UIImage* image2 = [UIImage imageWithData:imageBytes];
NSData* imageBytes2 = UIImageJPEGRepresentation(image2, 1.0);
NSLog(@"Size = %ld", imageBytes2.length);
...
第一个尺寸是 1,528,278,第二个尺寸是 4,289,184。 它们的大小不应该大致相同吗?
有没有办法指定 jpegStillImageNSDataRepresentation:imageSampleBuffer
的缩放和压缩?
最佳答案
显然,Apple 的 jpegStillImageNSDataRepresentation 默认压缩率为 0.85 左右。因此,通过将 UIImageJPEGRepresentation 设置为我得到相同的大小。
关于ios - 照片的JPEG NSData转UIImage转JPEG大小完全不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29153636/