Changeset 664 for trunk/src/get_file_type.m
- Timestamp:
- Jul 11, 2013, 11:56:47 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_file_type.m
r595 r664 30 30 FileType='xls'; 31 31 otherwise 32 if ~isempty(FileExt) && ~isempty(imformats(regexprep(FileExt,'^.',''))) 33 try 34 imainfo=imfinfo(fileinput); 35 if length(imainfo) >1 %case of image with multiple frames 36 FileType='multimage'; 37 FileInfo=imainfo(1);%take info from the first frame 38 FileInfo.NumberOfFrames=length(imainfo); 32 if ~isempty(FileExt)% exclude empty extension 33 FileExt=regexprep(FileExt,'^.','');% eliminate the dot of the extension 34 if ~isempty(FileExt) 35 if ~isempty(imformats(FileExt))%case of images 36 try 37 imainfo=imfinfo(fileinput); 38 if length(imainfo) >1 %case of image with multiple frames 39 FileType='multimage'; 40 FileInfo=imainfo(1);%take info from the first frame 41 FileInfo.NumberOfFrames=length(imainfo); 42 else 43 FileType='image'; 44 FileInfo=imainfo; 45 FileInfo.NumberOfFrames=1; 46 end 47 end 39 48 else 40 FileType='image'; 41 FileInfo=imainfo; 42 FileInfo.NumberOfFrames=1; 43 end 44 end 45 else 46 error_nc=0; 47 try 48 Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions',... 49 'CivStage','patch2','fix2','civ2','patch','fix'); 50 if isfield(Data,'Txt') && ~isempty(Data.Txt) 51 error_nc=1; 52 else 53 if ~isempty(Data.absolut_time_T0') 54 FileType='civx'; % test for civx velocity fields 55 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 56 FileInfo.CivStage=6; 57 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 58 FileInfo.CivStage=5; 59 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 60 FileInfo.CivStage=4; 61 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 62 FileInfo.CivStage=3; 63 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 64 FileInfo.CivStage=2; 65 elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) 66 FileInfo.CivStage=1; 49 error_nc=0; 50 try 51 Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions',... 52 'CivStage','patch2','fix2','civ2','patch','fix'); 53 if isfield(Data,'Txt') && ~isempty(Data.Txt) 54 error_nc=1; 55 else 56 if ~isempty(Data.absolut_time_T0') 57 FileType='civx'; % test for civx velocity fields 58 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 59 FileInfo.CivStage=6; 60 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 61 FileInfo.CivStage=5; 62 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 63 FileInfo.CivStage=4; 64 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 65 FileInfo.CivStage=3; 66 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 67 FileInfo.CivStage=2; 68 elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) 69 FileInfo.CivStage=1; 70 end 71 elseif strcmp(Data.Conventions,'uvmat/civdata') 72 FileType='civdata'; % test for civx velocity fields 73 FileInfo.CivStage=Data.CivStage; 74 else 75 FileType='netcdf'; 76 end 67 77 end 68 elseif strcmp(Data.Conventions,'uvmat/civdata') 69 FileType='civdata'; % test for civx velocity fields 70 FileInfo.CivStage=Data.CivStage; 71 else 72 FileType='netcdf'; 78 catch ME 79 error_nc=1; 73 80 end 74 end 75 catch ME 76 error_nc=1; 77 end 78 if error_nc 79 try 80 if exist('VideoReader.m','file')%recent version of Matlab 81 VideoObject=VideoReader(fileinput); 82 FileInfo=get(VideoObject); 83 FileType='video'; 84 elseif exist('mmreader.m','file')% Matlab 2009a 85 VideoObject=mmreader(fileinput); 86 FileInfo=get(VideoObject); 87 FileType='mmreader'; 88 end 89 FileInfo.BitDepth=FileInfo.BitsPerPixel/3; 81 if error_nc 82 try 83 if exist('VideoReader.m','file')%recent version of Matlab 84 VideoObject=VideoReader(fileinput); 85 FileInfo=get(VideoObject); 86 FileType='video'; 87 elseif exist('mmreader.m','file')% Matlab 2009a 88 VideoObject=mmreader(fileinput); 89 FileInfo=get(VideoObject); 90 FileType='mmreader'; 91 end 92 FileInfo.BitDepth=FileInfo.BitsPerPixel/3; 93 end 94 end 90 95 end 91 96 end
Note: See TracChangeset
for help on using the changeset viewer.