我需要以 512 字节的块将图像发送到服务器。
我得到的图像是:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[weakViewController dismissModalViewControllerAnimated:YES];
UIImage *shareImage = info[UIImagePickerControllerEditedImage];
imageData = UIImagePNGRepresentation(shareImage);
imageURL = [[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
imageURL = [NSString stringWithFormat:@"%@/%d.png",[StorageManager sharedManager].storagePath, (int)[[NSDate date] timeIntervalSince1970]];
[imageData writeToFile:imageURL atomically:YES];
NSString *imageUri = [NSString stringWithFormat:@"%@/%d.jpg",[StorageManager sharedManager].storagePath, (int)[[NSDate date] timeIntervalSince1970]];
[imageData writeToFile:imageUri atomically:YES];
}
//获取图片
fileData = [[NSFileManager defaultManager] contentsAtPath:imageURL];
file=[[message.fileURL pathComponents] lastObject];
有没有办法压缩图像(使文件数据更小)以最小化块到达目的地的时间?