![](/img/trans.png)
[英]How to show Image from document directory inside Gallery App IOS?
[英]Save last clicked image from gallery to document directory in ios
我想將保存在照片庫中的最后單擊的圖像保存到文檔目錄。 我該如何實現?
在您的代碼中更改NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0);
至
NSData * dataForJPEGFile = UIImageJPEGRepresentation(mimage,0.5);
此代碼0.5表示將壓縮圖像的50%。
- (void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName {
NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 0.5);
[dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] atomically:YES];
}
確保在PhotosAlbum中保存的照片尺寸和質量正確。 iOS存在問題,請參見鏈接: UIImageWriteToSavedPhotosAlbum保存的尺寸和質量錯誤
對於某些圖片,PNG格式將小於JPG格式。 您可以嘗試通過UIImagePNGRepresentation保存圖片。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.