Tag: uiimagejpegrepresentation

使用UIImageJPEGRepresentation时应该使用什么压缩质量?

我想对用户库中的照片应用filter,然后将其写回到磁盘。 我正在使用UIImageJPEGRepresentation 。 该函数使用UIImage和一个介于0.0和1.0之间的compressionQuality值。 因为我想保留原来的质量,我把它设置为1.0。 但是我发现这实际上创build了一个文件大小比原来大的图像文件,甚至更大一些。 我注意到在苹果的照片编辑扩展应用程序,他们总是把质量设置为0.9。 我试过了,它输出的文件大小接近原始照片文件大小。 这对我来说没有意义。 有人可以解释这个吗? 总是使用0.9是否合适? iOS相机是否使用该值压缩它,因此0.9是原始质量? 或者为什么0.9实际上不是1.0,如果没有什么更好的质量? NSData *renderedJPEGData = UIImageJPEGRepresentation(image, 0.9f);

UIImageJPEGRepresentation收到内存警告

在使用UIImageJPEGRepresentation时收到内存警告,有什么办法可以避免这种情况? 它不会崩溃的应用程序,但我想避免它,如果可能的话。 它间歇性地不运行[[UIApplication sharedApplication] openURL:url]; – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; NSData *imageToUpload = UIImageJPEGRepresentation(image, 1.0); // code that sends the image to a web service (omitted) // on success from the service // this sometime does not get run, I assume it has to do with the memory warning? […]

按大小压缩图像 – iPhone SDK

我想压缩图像(相机/照片库),然后将其发送到服务器。 我知道我可以按高度和宽度进行压缩,但是我想按大小将图像压缩到固定大小(200 KB),并保持原始高度和宽度。 JPEGRepresentation中的比例因子不代表大小,仅代表压缩质量。 我怎样才能达到这个(压缩到一个固定的大小),而不使用任何第三方库? 谢谢你的帮助。