0
我需要將圖像以512字節的塊形式發送到服務器。如何壓縮UIImage以便更快地將其發送到服務器
我剛剛接到圖像:
- (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];
有沒有辦法來COMPRESS圖像(使FILEDATA更小),以儘量減少大塊到達目的地的時間?
你能用.jpeg重構我的代碼嗎?如果我從照片庫中檢索文件.jpeg,我可以大幅縮小文件大小嗎?你能給我一個基於我發佈的內容的例子嗎?謝謝! – 2014-09-23 14:10:08