Hello Everyone, How can I check if someone uploads a video in MATLAB GUI using browse button instead of uploading an image?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello Everyone, How can I check if someone uploads a video in MATLAB GUI using browse button instead of uploading an image? I am developing tool for image processing and I want to apply a check on the browse button so whenever the end user try to upload a video, it will show an error message.
댓글 수: 4
Rik
2020년 4월 19일
You can use fileparts to extract the extension and compare it to the list of extensions imread supports. I don't have a suggestion for how you could generate a list of video formats, but if you just want to throw an error when the user doesn't select an image, this strategy should work for you.
답변 (2개)
Walter Roberson
2020년 4월 19일
Use try/catch on the imread. When the imread fails use try/catch on imfinfo; if it succeeds it was video (or possibly audio in container) and if it fails the file was not image or video.
댓글 수: 2
Walter Roberson
2020년 4월 19일
caution: Support for some formats is based on the contents of the file, not on the file extension. On some platforms if you rename an image file to the wrong extension then the code will detect the correct format instead of relying on the extension
Mehmed Saad
2020년 4월 19일
편집: Mehmed Saad
2020년 4월 19일
Try this
[Filename,Pathname] =uigetfile(...
{'*.png','PNG (*.png)';
'*.tif;*.tiff','TIFF (*.tif,*.tiff)';
'*.gif','GIF (*.gif)';
'*.jpg;*.jpeg;*.jpe;*.jfif','JPEG (*.jpg,*.jpeg,*.jpe,*.jfif)';
'*.bmp','BMP (*.bmp)';},'File Selector')
He can only select these types of file and is not possible for him select any other file
Also you can go with this too
[Filename,Pathname] =uigetfile(...
{'*.png;*.jpg;*.jpeg;*.jpe;*.jfif;*.tif;*.tiff;*.gif;*.bmp',...
'Image File(*.png,*.jpg,*.jpeg,*.jpe,*.jfif,*.tif,*.tiff,*.gif,*.bmp)'},'File Selector');
댓글 수: 5
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!