如何从图片中获取日期和文件大小? [英] How to get date and filesize from a picture?
本文介绍了如何从图片中获取日期和文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果从相册中将图片加载到应用程序中,如何获取以 MB 为单位的文件大小以及该图片在应用程序上显示的日期(如下面的屏幕截图所示)?
If pictures are loaded into an app from a album, how is it possible to get the filesize in MB and the date of that picture displayed on a app like on the screenshot below?
我知道您可以使用以下代码通过 NSLog 检索文件大小,但是我如何将其转换为字符串以及该图片的日期?
I know you can retrieve the filesize via a NSLog using the following code, but how can I get this into a string and also the date of that picture?
NSLog(@"size of image in KB: %i",[UIImagePNGRepresentation(UIImage) length]);
推荐答案
使用 CoreGraphics
Use CoreGraphics
size_t imageSize = CGImageGetBytesPerRow(image.CGImage) * CGImageGetHeight(image.CGImage);
这篇关于如何从图片中获取日期和文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文