簡體   English   中英

如何減小圖像jpeg / png的大小

[英]How decrease the size of image jpeg/png

我通過以下兩個參數使用以下方法創建圖像:一個是UIImage對象是imagdata,另一個NSString對象是storeImage

JPG: [UIImageJPEGRepresentation(imageData, 1.0) writeToFile:storeImage atomically:YES]; 或PNG: [UIImagePNGRepresentation(imageData) writeToFile:storeImage atomically:YES];

我的問題是,在我使用上述方法后,原始圖像大小為2.1 MB,在模擬器中圖像大小為4.2 MB。

我不想使用任何壓縮方法,也不想失去任何圖像質量。 我想復制圖像,因為它在給定的路徑。 實際尺寸。

使用圖像的簡單數據對象。嘗試以下代碼,其中NSData對象中的imageData。

[imageData writeToFile:storeImageically:YES];

你能告訴我原始尺寸和格式是什么嗎?
減小尺寸的一種方法是損失一點質量。

[UIImageJPEGRepresentation(imageData, 0.5) writeToFile:storeImage atomically:YES]

另一種方法是使用ImageIO框架。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM