[Cocoa]_[初级]_[获取图片文件的属性值:如图片大小、位深度、宽高、最后修改日期]

[Cocoa]_[初级]_[获取图片文件的属性值:如图片大小、位深度、宽高、最后修改日期],第1张

概述NSString *filePath = @"../work/png/11.png"; NSFileManager *fm =[NSFileManager defaultManager]; if ([fm fileExistsAtPath:filePath]) { NSString *filepathName =[filePath lastPathCompo
    Nsstring *filePath = @"../work/png/11.png";    NSfileManager *fm =[NSfileManager defaultManager];    if ([fm fileExistsAtPath:filePath])    {        Nsstring *filepathname =[filePath lastPathComponent];                       NSDictionary *attr =[fm attributesOfItemAtPath:filePath error:nil];         //获取图片文件的大小        int sizeValue =[[attr objectForKey:NSfileSize] intValue];           //图片文件的最后修改时间        Nsstring *modifIEdString = [attr objectForKey:NSfileModificationDate] ;        [lastModifIEdFIEld setStringValue:[Nsstring stringWithFormat:@"Last modifIEd:%@",modifIEdString]];        NSData *data =[[NSData alloc] initWithContentsOffile:filePath];        NSImage *showImage = [[NSImage alloc] initWithData:data] ;        if(showImage != nil && [showImage isValID] )        {           //图片的宽高           Nsstring *imageSize = [Nsstring stringWithFormat:@"Dimensions: %0.0f * %0.0f px",showImage.size.wIDth,showImage.size.height];          //图片的位深度值           NSData *imageData =[showImage TIFFRepresentation];           NSBitmAPImageRep *bitmapRep =[[NSBitmAPImageRep alloc] initWithData:imageData];           int pixel = [bitmapRep bitsPerPixel];         }
总结

以上是内存溢出为你收集整理的[Cocoa]_[初级]_[获取图片文件的属性值:如图片大小、位深度、宽高、最后修改日期]全部内容,希望文章能够帮你解决[Cocoa]_[初级]_[获取图片文件的属性值:如图片大小、位深度、宽高、最后修改日期]所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1052324.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存