我有一個從ALAssetLibrary檢索到的對象ALAsset我想推斷一個壓縮JPEG以便將其發送到Web服務。如何從ALAsset保存壓縮的JPEG
任何建議從哪裏開始?
編輯: 我找到一種方式來獲得的NSData出ALAsset
ALAssetRepresentation *rappresentation = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rappresentation.size);
NSUInteger buffered = [rappresentation getBytes:buffer fromOffset:0.0 length:rappresentation.size error:&err];
的,但我不能找到一種方法,通過調整和壓縮它,以減少圖像的大小。 我的想法是有類似:
UIImage *myImage = [UIImage imageWithData:data];
//resize image
NSData *compressedData = UIImageJPEGRepresentation(myImage, 0.5);
但是,首先,即使沒有調整,只是用代碼compressedData的這兩條線比數據更大。 和第二我不知道什麼是對調整的UIImage